You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by an...@apache.org on 2001/08/08 08:58:52 UTC

cvs commit: xml-xerces/java/src/org/apache/xerces/parsers AbstractSAXParser.java DOMParser.java

andyc       01/08/07 23:58:51

  Modified:    java/src/org/apache/xerces/parsers Tag: xerces_j_2
                        AbstractSAXParser.java DOMParser.java
  Log:
  Fixed problem where XNIExceptions were "leaking" out from the
  parse(String) method. Now they are explicitly caught and
  wrapped as SAXExceptions before being re-thrown to the
  application.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.18  +21 -4     xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractSAXParser.java
  
  Index: AbstractSAXParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/Attic/AbstractSAXParser.java,v
  retrieving revision 1.1.2.17
  retrieving revision 1.1.2.18
  diff -u -r1.1.2.17 -r1.1.2.18
  --- AbstractSAXParser.java	2001/08/02 05:47:38	1.1.2.17
  +++ AbstractSAXParser.java	2001/08/08 06:58:51	1.1.2.18
  @@ -106,7 +106,7 @@
    * @author Arnaud Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: AbstractSAXParser.java,v 1.1.2.17 2001/08/02 05:47:38 andyc Exp $ 
  + * @version $Id: AbstractSAXParser.java,v 1.1.2.18 2001/08/08 06:58:51 andyc Exp $ 
    */
   public abstract class AbstractSAXParser
       extends AbstractXMLDocumentParser
  @@ -886,7 +886,22 @@
               parse(source);
           }
   
  -        // close opened stream
  +        // wrap XNI exceptions as SAX exceptions
  +        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);
  +        }
  +
  +        // close stream opened by the parser
           finally {
               try {
                   Reader reader = source.getCharacterStream();
  @@ -918,8 +933,8 @@
       public void parse(InputSource inputSource) 
           throws SAXException, IOException {
   
  +        // parse document
           try {
  -            reset();
               XMLInputSource xmlInputSource = 
                   new XMLInputSource(inputSource.getPublicId(),
                                      inputSource.getSystemId(),
  @@ -927,8 +942,10 @@
               xmlInputSource.setByteStream(inputSource.getByteStream());
               xmlInputSource.setCharacterStream(inputSource.getCharacterStream());
               xmlInputSource.setEncoding(inputSource.getEncoding());
  -            fConfiguration.parse(xmlInputSource);
  +            parse(xmlInputSource);
           }
  +
  +        // wrap XNI exceptions as SAX exceptions
           catch (XNIException e) {
               Exception ex = e.getException();
               if (ex == null) {
  
  
  
  1.19.2.19 +20 -2     xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java
  
  Index: DOMParser.java
  ===================================================================
  RCS file: /home/cvs/xml-xerces/java/src/org/apache/xerces/parsers/DOMParser.java,v
  retrieving revision 1.19.2.18
  retrieving revision 1.19.2.19
  diff -u -r1.19.2.18 -r1.19.2.19
  --- DOMParser.java	2001/07/24 08:10:34	1.19.2.18
  +++ DOMParser.java	2001/08/08 06:58:51	1.19.2.19
  @@ -88,7 +88,7 @@
    * @author Arnaud  Le Hors, IBM
    * @author Andy Clark, IBM
    *
  - * @version $Id: DOMParser.java,v 1.19.2.18 2001/07/24 08:10:34 andyc Exp $ 
  + * @version $Id: DOMParser.java,v 1.19.2.19 2001/08/08 06:58:51 andyc Exp $ 
    */
   public class DOMParser
       extends AbstractDOMParser {
  @@ -151,7 +151,22 @@
               parse(source);
           }
   
  -        // close opened stream
  +        // wrap XNI exceptions as SAX exceptions
  +        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);
  +        }
  +
  +        // close stream opened by the parser
           finally {
               try {
                   Reader reader = source.getCharacterStream();
  @@ -183,6 +198,7 @@
       public void parse(InputSource inputSource) 
           throws SAXException, IOException {
   
  +        // parse document
           try {
               XMLInputSource xmlInputSource = 
                   new XMLInputSource(inputSource.getPublicId(),
  @@ -193,6 +209,8 @@
               xmlInputSource.setEncoding(inputSource.getEncoding());
               parse(xmlInputSource);
           }
  +
  +        // wrap XNI exceptions as SAX exceptions
           catch (XNIException e) {
               Exception ex = e.getException();
               if (ex == null) {
  
  
  

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