You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by mr...@apache.org on 2008/05/08 04:28:50 UTC

svn commit: r654392 - /xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java

Author: mrglavas
Date: Wed May  7 19:28:50 2008
New Revision: 654392

URL: http://svn.apache.org/viewvc?rev=654392&view=rev
Log:
Before returning control to the user, disconnect the validator and other
objects from the XMLReader. This keeps the user's application from mucking around
with the Validator's internal ValidatorHandler and may allow for better garbage
collection.

Modified:
    xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java

Modified: xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java
URL: http://svn.apache.org/viewvc/xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java?rev=654392&r1=654391&r2=654392&view=diff
==============================================================================
--- xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java (original)
+++ xerces/java/branches/xml-schema-1.1-dev/src/org/apache/xerces/jaxp/validation/ValidatorHandlerImpl.java Wed May  7 19:28:50 2008
@@ -663,8 +663,9 @@
                 setContentHandler(ch);
             }
             
+            XMLReader reader = null;
             try {
-                XMLReader reader = saxSource.getXMLReader();
+                reader = saxSource.getXMLReader();
                 if (reader == null) {
                     // create one now
                     SAXParserFactory spf = SAXParserFactory.newInstance();
@@ -716,8 +717,21 @@
                 reader.parse(is);
             } 
             finally {
-                // release the reference to user's handler ASAP
+                // Release the reference to user's ContentHandler ASAP
                 setContentHandler(null);
+                // Disconnect the validator and other objects from the XMLReader
+                if (reader != null) {
+                    try {
+                        reader.setContentHandler(null);
+                        reader.setDTDHandler(null);
+                        reader.setErrorHandler(null);
+                        reader.setEntityResolver(null);
+                        fResolutionForwarder.setEntityResolver(null);
+                        reader.setProperty(LEXICAL_HANDLER, null);
+                    }
+                    // Ignore the exception if the lexical handler cannot be unset.
+                    catch (Exception exc) {}
+                }
             }
             return;
         }



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