[ http://issues.apache.org/jira/browse/XERCESJ-444?page=all ]

Michael Glavassevich reassigned XERCESJ-444:
--------------------------------------------

    Assignee: Michael Glavassevich  (was: Xerces-J Developers Mailing List)

> SAXException thrown by EntityResolver is reported as IOException
> ----------------------------------------------------------------
>
>                 Key: XERCESJ-444
>                 URL: http://issues.apache.org/jira/browse/XERCESJ-444
>             Project: Xerces2-J
>          Issue Type: Bug
>          Components: SAX
>    Affects Versions: 2.0.2
>         Environment: Operating System: Windows XP
> Platform: PC
>            Reporter: Kohsuke Kawaguchi
>         Assigned To: Michael Glavassevich
>         Attachments: ExceptionBuilder.java, jira_444_alt_patch.txt, 
> jira_444_patch.txt
>
>
> 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);
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to