You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by "Rosen, Alex" <ar...@silverstream.com> on 2000/07/19 02:11:45 UTC

Closing InputSource streams

The SAX documentation doesn't make it clear whether the SAX parser is supposed
to close an InputSource's Reader/InputStream or not. I'd assume that it would
not, without mentioning this fact. But searching through the Xerces code for
"new InputSource", I came across different code that assumes different answers:

XMLValidator.Resolver and TraverseSchema.Resolver hand an InputStream to the
InputSource, and forget about it (they don't close it). The sample code in the
JavaDoc for EntityResolver does the same thing.

XMLParser.parse(String systemId) says that it's equivalent to "parse(new
InputSource(systemId))", but that's wrong, it does more. It creates an
InputSource from a String, but then closes the source's Reader/InputStream.
(This is even more confusing for me. The docs don't say that you have to do
this.)

By contrast, DocumentBuilder and many other classes simply create the new
InputSource(systemId) and forget about it.

What is the actual behavior? I wish this were better documented.

Thanks!
Alex