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 bu...@apache.org on 2001/09/28 00:14:01 UTC
DO NOT REPLY [Bug 3862] New: -
DocumentBuilder.parse(InputStream) closes InputStream
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3862>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND
INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=3862
DocumentBuilder.parse(InputStream) closes InputStream
Summary: DocumentBuilder.parse(InputStream) closes InputStream
Product: Xerces-J
Version: 1.4.3
Platform: PC
OS/Version: Windows NT/2K
Status: NEW
Severity: Normal
Priority: Other
Component: JAXP
AssignedTo: xerces-j-dev@xml.apache.org
ReportedBy: aaronk@geniesystems.com
When calling DocumentBuilder.parse(InputStream in), parsing continues until end
of stream, at which point the stream in closed. When parsing input from a
Socket, this closes the Socket, too, meaning that you can't write your response
back to the OutputStream.
The correct way of shuting down a SocketInputStream is to call
socket.shutDownInput(). Obviously, an XML parser should not be expected to do
this (it doesn't have a handle to the Socket, for a start).
I don't believe that closing any InputStream passed as a parameter to a method
is good design, as this places additional contractual constraints between the
class implementating that method and the class calling the method. A better
approach would be to require the calling code to close the stream after the
call to parse.
If the code that creates the stream, closes the stream, then responsibilities
are clearly defined. (This also becomes an application of the template method
design pattern.)
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org