Menu ▾ ▴

#59 BufferedOutputStream close bug

open
nobody
5
2002-12-03
2002-12-03
No

I also encountered the bugs described in Request IDs
484933, 547447 in Lumberjack 0.9.3. The bug occurs
because of the following line in FileHandler.switchFiles():
<p>
buffered.close();
<p>
This line closes the buffered stream before
setOutputStream( OutputStream ) is called. When
setOutputStream is called, it writes headers and trailers
if needed, and then closes the writer --- but the output
stream the writer is using has already been closed, so
an IOException is thrown. This explains why the trailer
never gets written. The SimpleFormatter doesn't write
any trailer, so the bug doesn't show up. When using
the XMLFormatter, the IOException is thrown every time
a file switch happens, but the error is only reported on
the first switch because ErrorManager only prints the
first error (by design).

My fix is to delete the line in FileHandler.switchFiles()
that closes the buffered output stream.
StreamHandler.setOutputStream( OutputStream )
writes the header and trailer as needed, closes the
writer (and therefore the underlying stream), and then
switches to the next file.

Discussion


Log in to post a comment.