JDK-8190919 :StaX buffers do not really close underlying buffers

huizhe wang huizhe.wang at oracle.com
Thu Nov 16 17:23:42 UTC 2017


Hi Srividya,

There had been for and against XMLStreamWriter/Reader closing the 
underlying stream, about 10 years ago, both had use cases. There is a 
legitimate argument that the XML writer/reader shall be consistent with 
java.io. Unfortunately, the later (not closing) won because that's 
indeed what the spec  (JSR 173 1.0) required: "This must not close the 
underlying output stream." [1]   Given the spec, I'll close the bug 
(8190919) as not-an-issue.

[1] 
https://docs.oracle.com/javase/8/docs/api/javax/xml/stream/XMLStreamWriter.html#close--

Regards,
Joe

On 11/16/2017 1:23 AM, Srividya Shamaiah wrote:
>
> Hello,
>
> Am not sure to which mailing-list, I can send issues related to xml-jaxp. I
> found couple of xml-jaxp issues discussed in this mailing-list. Hence, am
> sending to this group. Please let me know the correct mailing-list if this
> is not the right one.
>
> I had a brief analysis on the subject issue and identified that the StaX
> buffers were not closed as the close method implemented for XMLStreamWriter
> in  XMLStreamWriterImpl.java does not call the close on the underlying
> writer and instead calls only flush()  on the writer.
>
> Interestingly the close call was in fact coded but commented out. We looked
> into the history of XMLStreamWriterImpl.java and found that the same code
> exists from Java 6 GA or even before. Hence, we could not find the bug
> which really introduced/commented out the close call.
>
> I tested with close uncommented and it resolve the issue. I did not run the
> jtreg and other tests as I could see that  the bug is already assigned
> to Joe Wang.
>
> @Joe, please let me know whether you will continue with the analysis or you
> want me to do other tests and contribute the patch.
>
> With Thanks and Regards,
> Srividya S



More information about the core-libs-dev mailing list