sandygao    2003/03/03 11:15:32

  Modified:    java/src/org/apache/xerces/impl/xs XMLSchemaLoader.java
                        XMLSchemaValidator.java
  Log:
  Fixing a bug in using the Schema Decl Pool.
  When a grammar is preparsed, even if there is no grammar pool, we still can't
  use a decl pool, because the application might store the grammar somewhere,
  and the decl objects shouldn't be recycled by the decl pool.
  Now the decl pool is only used when the schema loader is called by the schema
  validator, and no grammar pool is set.
  
  Revision  Changes    Path
  1.17      +16 -9     
xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java
  
  Index: XMLSchemaLoader.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaLoader.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- XMLSchemaLoader.java      29 Jan 2003 15:06:32 -0000      1.16
  +++ XMLSchemaLoader.java      3 Mar 2003 19:15:31 -0000       1.17
  @@ -451,24 +451,31 @@
                                                                    
XMLErrorReporter.SEVERITY_WARNING);
                   }
               }
  -            fCMBuilder.setDeclPool(null);
  -        } else {
  -            fDeclPool.reset();
  -            fCMBuilder.setDeclPool(fDeclPool);
           }
  -
  -        fSchemaHandler.reset(fErrorReporter, fEntityResolver,
  -                fSymbolTable, fGrammarPool, fAllowJavaEncodings, fStrictURI);
  -        if(fGrammarPool == null) {
  +        
  +        if (useDeclPool) {
               fDeclPool.reset();
  +            fCMBuilder.setDeclPool(fDeclPool);
               fSchemaHandler.setDeclPool(fDeclPool);
           } else {
  +            fCMBuilder.setDeclPool(null);
               fSchemaHandler.setDeclPool(null);
           }
  +
  +        fSchemaHandler.reset(fErrorReporter, fEntityResolver,
  +                fSymbolTable, fGrammarPool, fAllowJavaEncodings, fStrictURI);
           fSubGroupHandler.reset();
           fJAXPProcessed = false;
       } // reset()
   
  +    // useDeclPool is only set to true when the validator invokes the loader,
  +    // and there is no grammar pool. that is, the grammar will never be
  +    // exposed to the application.
  +    private boolean useDeclPool = false;
  +    public void setUseDeclPool(boolean use) {
  +        useDeclPool = use;
  +    }
  +    
       /**
        * Returns a Grammar object by parsing the contents of the
        * entity pointed to by source.
  
  
  
  1.134     +5 -1      
xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java
  
  Index: XMLSchemaValidator.java
  ===================================================================
  RCS file: 
/home/cvs/xml-xerces/java/src/org/apache/xerces/impl/xs/XMLSchemaValidator.java,v
  retrieving revision 1.133
  retrieving revision 1.134
  diff -u -r1.133 -r1.134
  --- XMLSchemaValidator.java   23 Jan 2003 17:27:11 -0000      1.133
  +++ XMLSchemaValidator.java   3 Mar 2003 19:15:31 -0000       1.134
  @@ -1363,6 +1363,10 @@
               fGrammarPool = null;
           }
           fSchemaLoader.setProperty(XMLGRAMMAR_POOL, fGrammarPool);
  +        // only set useDeclPool to true when the validator invokes the loader,
  +        // and there is no grammar pool. that is, the grammar will never be
  +        // exposed to the application.
  +        fSchemaLoader.setUseDeclPool(fGrammarPool == null);
   
           // Copy the allow-java-encoding feature to the grammar loader.
           // REVISIT: what other fetures/properties do we want to copy?
  
  
  

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

Reply via email to