Bug #2382
closedUnclosed Emitter writter
100%
Description
Bug reported on sourceforge support by Xianhua Liu:
-
In Controller, both transformStream and transformDocument call openMessageEmitter in the beginning and closeMessageEmitter at the end. If any exception is thrown between, closeMessageEmitter will never get called. Please consider adding try-catch-finally block and call closeMessageEmitter in the finally block.
-
In openMessageEmitter function, setWriter is called to set Emitter writer to a OutputStreamWriter wrapping the system error output. This writer never gets closed. It is not closed inside the Controller class, neither is it closed by calling the Emitter.close function through closeMessageEmitter function. It should be closed in a finally block as mentioned.
Updated by Michael Kay over 9 years ago
- Status changed from New to In Progress
The bug report as written relates to the 9.5 code. The first point about calling closeMessageEmitter() applies equally to 9.6. The second point about closing the stream underlying the message emitted has changed for 9.6, because we now write to a Logger supplied by the Configuration.
For 9.6 I have patched the methods that call openMessageEmitter() so that they now call closeMessageEmitter() in a finally block.
On the second point, although 9.6 goes via the Logger, it's still true that we don't close System.err after use. I don't believe that it's correct to do so. The normal rule that we apply is "whoever creates a stream or writer is responsible for closing it." We don't create System.err, therefore we don't close it. (OK, I know that principle is problematic. If you do "x = new OutputStreamWriter(System.err), then calling x.close() will have the effect of closing System.err, even though you didn't create System.err. But we try to stick to the principle.
Updated by Michael Kay over 9 years ago
- Status changed from In Progress to Resolved
Fixed in he 9.6 and 9.7 branches
Updated by O'Neil Delpratt over 9 years ago
- Status changed from Resolved to Closed
- % Done changed from 0 to 100
- Fixed in version set to 9.6.0.7
Bug fix applied in the Saxon 9.6.0.7 maintenance release.
Updated by O'Neil Delpratt almost 9 years ago
- Applies to branch 9.6 added
- Fix Committed on Branch 9.6 added
- Fixed in Maintenance Release 9.6.0.7 added
Please register to edit this issue