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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to