JDK-5019622 : unmarshaller closes the inputstream it doesn't own
  • Type: Enhancement
  • Component: xml
  • Sub-Component: org.xml.sax
  • Affected Version: 1.0.2
  • Priority: P4
  • Status: Closed
  • Resolution: Not an Issue
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2004-03-24
  • Updated: 2012-04-25
  • Resolved: 2004-06-06
Name: gm110360			Date: 03/24/2004


When asking to unmarshal on a given inputstream, the stream gets a call to close(). This should not happen since the unmarshaller did not open the stream
(symetry reason).

For example:

If you open a zipinputstream, and one zipentry is the xml you want to parse,
you have to pass the zipinputstream, but since it gets close(), you can't continue to read other  zip entries.

This bug can be reproduced always.
(Incident Review ID: 237540) 

EVALUATION This is not a bug. See the class javadoc of http://www.saxproject.org/apidoc/org/xml/sax/InputSource.html An XML parser is responsible for closing the stream. Since JAXB uses a parser underneath, I think the behavior you are seeing is the correct behavior. The workaround would be to use a FilterInputStream that ignores the close method, as you have already found. ###@###.### 2004-03-24 As per the request from the submitter, I'm re-opening this and forwarding it to the JAXP team. Also, since the current behavior is compliant to the specification of SAX, and the submitter is requesting for a change in the spec, I changed this from a bug to an RFE. ###@###.### 2004-03-26 the latest version of the SAX specification for InputSource states: "An InputSource object belongs to the application: the SAX parser shall never modify it in any way (it may modify a copy if necessary). However, standard processing of both byte and character streams is to close them on as part of end-of-parse cleanup, so applications should not attempt to re-use such streams after they have been handed to a parser." if this behavior needs to be changed, it must go through the SAX community: http://www.saxproject.org/ as JAXP uses SAX as is in standard form, this bug is being closed. any modifications made to SAX will be picked up by JAXP. ###@###.### 2004-06-06