Project

Profile

Help

Bug #2382

closed

Unclosed Emitter writter

Added by O'Neil Delpratt almost 9 years ago. Updated over 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
Internals
Sprint/Milestone:
Start date:
2015-05-20
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
9.6
Fix Committed on Branch:
9.6
Fixed in Maintenance Release:
Platforms:

Description

Bug reported on sourceforge support by Xianhua Liu:

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

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

Actions #1

Updated by Michael Kay almost 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.

Actions #2

Updated by Michael Kay almost 9 years ago

  • Status changed from In Progress to Resolved

Fixed in he 9.6 and 9.7 branches

Actions #3

Updated by O'Neil Delpratt over 8 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.

Actions #4

Updated by O'Neil Delpratt over 8 years ago

  • Applies to branch 9.6 added
  • Fix Committed on Branch 9.6 added
  • Fixed in Maintenance Release 9.6.0.7 added
Actions #5

Updated by O'Neil Delpratt over 8 years ago

  • Sprint/Milestone set to 9.6.0.7

Please register to edit this issue

Also available in: Atom PDF