• Hasseman (unregistered)

    Frist of all parsing a logfile cannotbe the moost important work he has done in 8 years

  • capt bullshot (unregistered)

    Result contains "File not found", so its type clearly must be boolean.

  • ray10k (unregistered) in reply to Hasseman

    Fair enough, but I do think this is a good example of the kind of "quality" he provided.

  • someone (unregistered)

    If readLine() moves the file pointer, then this will skip a lot of lines at the beginning of each iteration.

  • bs franklin (unregistered) in reply to someone

    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?

  • ray10k (unregistered) in reply to someone

    It does. And the program does skip every other line as a result. Even more if the program gets that out-of-memory error.

  • Mr. TA (unregistered)

    Haha this is very bad code. I can't believe stuff like this exists.

  • (nodebb) in reply to ray10k

    It does. And the program does skip every other line as a result. Even more if the program gets that out-of-memory error.

    That must be how it's optimized for speed, no?

  • Little Bobby Tables (unregistered)

    "... end customer's only in-house developer, Tyrell, ..."

    I think I've found TRWTF.

  • RichP (unregistered)

    Err, according to the documentation, it looks like all you need to do is cat $log_file_name

  • isthisunique (unregistered)

    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?

  • pld (unregistered)

    I love how delightfully meaningless the following bit of the documentation is:

    • If found it returns the file contents with the string. Otherwise it
    • returns the file contents without it.

    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."

  • tango_uniform (unregistered)

    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...

  • Dave (unregistered)

    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.

  • wow (unregistered)

    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.

Leave a comment on “Knowledge Transfer”

Log In or post as a guest

Replying to comment #498391:

« Return to Article