- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Frist of all parsing a logfile cannotbe the moost important work he has done in 8 years
Admin
Result contains "File not found", so its type clearly must be boolean.
Admin
Fair enough, but I do think this is a good example of the kind of "quality" he provided.
Admin
If
readLine()
moves the file pointer, then this will skip a lot of lines at the beginning of each iteration.Admin
If no exception occurs reading the file, then it skips every other line. When the out of memory error occurs, it cleans up and tries to read in more lines from the rest of the file? So which will happen frist, OutOfMemory or StackOverflow from the recursion in the finally?
Admin
It does. And the program does skip every other line as a result. Even more if the program gets that out-of-memory error.
Admin
Haha this is very bad code. I can't believe stuff like this exists.
Admin
That must be how it's optimized for speed, no?
Admin
"... end customer's only in-house developer, Tyrell, ..."
I think I've found TRWTF.
Admin
Err, according to the documentation, it looks like all you need to do is
cat $log_file_name
Admin
It's hard to believe this isn't fake. A finally that makes an infinite loop? It looks like it re-reads the entire file from scratch each time it reads to the end. Out of memory will cause it to retry infinitely, and each time adding the lines to result at some point gc will reap all that can be reaped and then bad things will happen. It's just reading the first two lines over and over recursively? Then if OOM extend it each time by 10 to 19 lines to be read? So basically, it depends on an OOM to cause it to start reading the rest of the file? Then there's the assume an exception is a file not found exception. Actually the OOM thing isn't like that, since there's the outer while with readline, however, isn't it going to skip storing and checking every first line of three, store every second and third line of three, only check every third line of three but when there's an OOM it'll result in STORING more lines and checking less. It's like the fizzbuzz of log parsing with a nasty surprise at the end. Setting the line to the string retry is useless. I wonder if that was the fix for the extreme fringe case of the line read was really long, so much so result.add ran out of memory when trying to expand. Contains as well instead of starts with?
Admin
I love how delightfully meaningless the following bit of the documentation is:
It's like saying, "This method looks in my bank account for a million dollars. If found, it returns my current balance including the million dollars. If not, it returns my current balance without including a million dollars."
Admin
Funny, there's a movie based on a book that sounds a lot like what's going on here...Johnny Mnemonic. I guess our hero had similar information overload problems...
Admin
TRWTF here is the HPC not telling them that what they wanted couldn't be done, and instead accepting money for non-performance of an impossible task. Tut tut.
Admin
The code was easy to follow. It just looked like code you'd see out of a new college grad that never has used Java but was good at keeping things clean, tidy and understandable in other languages.
So, the code basically crashes when run. I'd start by a "where used" check and see if it can get nuked. That's probably the first task the next dev should get involved with.