You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by mk...@apache.org on 2004/11/22 18:53:43 UTC

cvs commit: xml-xalan/java/src/org/apache/xml/dtm/ref DTMManagerDefault.java

mkwan       2004/11/22 09:53:43

  Modified:    java/src/org/apache/xml/dtm/ref DTMManagerDefault.java
  Log:
  Fix a memory leak problem in DTMManager (JIRA bug 1999).
  
  Revision  Changes    Path
  1.52      +21 -3     xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java
  
  Index: DTMManagerDefault.java
  ===================================================================
  RCS file: /home/cvs/xml-xalan/java/src/org/apache/xml/dtm/ref/DTMManagerDefault.java,v
  retrieving revision 1.51
  retrieving revision 1.52
  diff -u -r1.51 -r1.52
  --- DTMManagerDefault.java	16 Feb 2004 23:06:11 -0000	1.51
  +++ DTMManagerDefault.java	22 Nov 2004 17:53:43 -0000	1.52
  @@ -49,7 +49,7 @@
   import org.xml.sax.SAXNotRecognizedException;
   import org.xml.sax.SAXNotSupportedException;
   import org.xml.sax.XMLReader;
  -import org.xml.sax.helpers.XMLReaderFactory;
  +import org.xml.sax.helpers.DefaultHandler;
   
   /**
    * The default implementation for the DTMManager.
  @@ -111,6 +111,11 @@
      * supply an XMLReader for a SAXSource or supplied a StreamSource.
      */
     protected XMLReaderManager m_readerManager = null;
  +  
  +  /**
  +   * The default implementation of ContentHandler, DTDHandler and ErrorHandler.
  +   */
  +  protected DefaultHandler m_defaultHandler = new DefaultHandler();
   
     /**
      * Add a DTM to the DTM table. This convenience call adds it as the 
  @@ -264,6 +269,7 @@
   
         if (isSAXSource || isStreamSource) {
           XMLReader reader = null;
  +        SAX2DTM dtm;
   
           try {
             InputSource xmlSource;
  @@ -288,7 +294,6 @@
               }
             }
   
  -          SAX2DTM dtm;
             if (source==null && unique && !incremental && !doIndexing) {
               // Special case to support RTF construction into shared DTM.
               // It should actually still work for other uses,
  @@ -448,6 +453,19 @@
   
             return dtm;
           } finally {
  +          // Reset the ContentHandler, DTDHandler, ErrorHandler to the DefaultHandler
  +          // after creating the DTM.
  +          if (reader != null && !(m_incremental && incremental)) {
  +            reader.setContentHandler(m_defaultHandler);
  +            reader.setDTDHandler(m_defaultHandler);
  +            reader.setErrorHandler(m_defaultHandler);
  +            
  +            // Reset the LexicalHandler to null after creating the DTM.
  +            try {
  +              reader.setProperty("http://xml.org/sax/properties/lexical-handler", null);
  +            }
  +            catch (Exception e) {}
  +          }
             releaseXMLReader(reader);
           }
         } else {
  
  
  

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