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 Brad O'Hearne <ca...@megapathdsl.net> on 2001/03/02 19:05:40 UTC

RE: Explicit file closing

Hey all,

I hate to be redundant here :-), but I am hoping the key to getting feedback
is persistence. :-)  In looking through the source code, I am not seeing
where the SAXParser is being closed when an exception is thrown out of the
parsing of the XML file.  (i.e. the parse(String uri) method in the
XMLReader class is interrupted by the throwing of an Exception).  This is
directly causing a problem in my application because the XMLReader is not
letting go of the file when this Exception is thrown, which prevents further
file operations (like moving the file).  If I am wrong in this observation,
if someone would please correct me, I would be greatly appreciative.  If I
am right, then the file either needs to be closed when the Exception is
thrown, OR there needs to be a method available that allows explicit closing
of the XML file.

Thanks!

BradO

-----Original Message-----
From: Brad O'Hearne [mailto:cabodog@megapathdsl.net]
Sent: Tuesday, February 27, 2001 11:04 PM
To: xerces-j-user@xml.apache.org; xerces-j-dev@xml.apache.org
Subject: RE: Explicit file closing


Has anyone been able to verify this problem, or have any ideas on the
solution?

BradO

-----Original Message-----
From: Brad O'Hearne [mailto:cabodog@megapathdsl.net]
Sent: Friday, February 23, 2001 7:48 PM
To: xerces-j-user@xml.apache.org; xerces-j-dev@xml.apache.org
Subject: RE: Explicit file closing


I was looking through the source on this in the
org.apache.xerces.framework.XMLParser class, and it appears that the
parse(String systemId) method does not close the InputSource if an Exception
is thrown -- it appears parsing has to end gracefully for this to happen.
This would also be consistent with the results I am getting below (if an
Exception, the file is locked, if it ends gracefully, the file is free).
Perhaps I am overlooking something, but the parse method isn't inside a
try-catch.  If I have read this correctly, I would throw the call to the
parse(InputSource is) that resides inside the parse(String systemId) method
inside a try-catch block with a finally that closes the InputSource.  Let me
know if this seems right -- perhaps I missed something.

Thanks in advance,

BradO

-----Original Message-----
From: Brad O'Hearne [mailto:cabodog@megapathdsl.net]
Sent: Friday, February 23, 2001 6:55 PM
To: xerces-j-user@xml.apache.org
Subject: Explicit file closing


Hello all,

I ran into an interesting problem tonight.  I am using a SAX2 parser.  My
app moves my xml file to a new directory immediately following parsing, or
if parsing is aborted after a SAXException is thrown.  I am getting an
access conflict on the file trying to move my file following a SAXException
being thrown and parsing being aborted.  I have checked the XMLReader
interface and noticed that there are no methods declared for explicitly
closing the underlying file.  Is there some way for the app to explicitly
control the closing of the file, and if not, should this be added?  (I guess
another question is when exactly is the file being closed now?)

Thanks in advance for help!

BradO


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org