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 2002/08/24 03:19:02 UTC
DO NOT REPLY [Bug 11999] New: -
SAXException thrown by EntityResolver is reported as IOException
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=11999>.
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=11999
SAXException thrown by EntityResolver is reported as IOException
Summary: SAXException thrown by EntityResolver is reported as
IOException
Product: Xerces2-J
Version: 2.0.2
Platform: PC
OS/Version: Windows XP
Status: NEW
Severity: Normal
Priority: Other
Component: SAX
AssignedTo: xerces-j-dev@xml.apache.org
ReportedBy: kk@kohsuke.org
If I throw a SAXException that has an IOException as its nested exception from
EntityResolver, the parser will report it as IOException, not as SAXException.
Here is what happens. The SAXException thrown by an EntityResolver is first
catched by org.apache.xerces.utilEntityResolverWrapper. The following code is
in the catch block
> // error resolving entity
> catch (SAXException e) {
> Exception ex = e.getException();
> if (ex == null) {
> ex = e;
> }
> throw new XNIException(ex);
> }
Since the SAXException I throw has a nested exception, an XNIException with
nested IOException will be re-thrown from here.
This exception will be relayed by several components, and eventually it will
come to the parse method of the org.apache.xerces.parsers.AbstractSAXParser
class.
(line.1194)
> catch (XNIException e) {
> Exception ex = e.getException();
> if (ex == null) {
> throw new SAXException(e.getMessage());
> }
> if (ex instanceof SAXException) {
> throw (SAXException)ex;
> }
> if (ex instanceof IOException) {
> throw (IOException)ex;
> }
> throw new SAXException(ex);
> }
Since the nested exception is IOException, it will be thrown as IOException.
The net effect is that my application handler will receive an IOException even
though I threw a SAXException.
I believe this is a bug; I should receive what I threw.
It seems to me that the bug is in the catch block of EntityResolverWrapper. It
should just wrap the SAXException into XNIException, instead of trying to
unwrap it. So the code should be just:
// error resolving entity
catch (SAXException e) {
throw new XNIException(e);
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org