yoavs       2004/09/02 07:20:22

  Modified:    catalina/src/share/org/apache/catalina/startup
                        DigesterFactory.java
  Log:
  Added a Log for logging and NPE checking around null resource URLs (Bugzilla 30636)
  
  Revision  Changes    Path
  1.8       +22 -10    
jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/DigesterFactory.java
  
  Index: DigesterFactory.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-catalina/catalina/src/share/org/apache/catalina/startup/DigesterFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- DigesterFactory.java      26 Jun 2004 17:41:31 -0000      1.7
  +++ DigesterFactory.java      2 Sep 2004 14:20:22 -0000       1.8
  @@ -32,6 +32,11 @@
    * @author Jean-Francois Arcand
    */
   public class DigesterFactory {
  +    /**
  +     * The log.
  +     */
  +   protected static org.apache.commons.logging.Log log = 
  +       org.apache.commons.logging.LogFactory.getLog(DigesterFactory.class);
   
       /**
        * The XML entiry resolver used by the Digester.
  @@ -50,7 +55,7 @@
       
       /**
        * Create a <code>Digester</code> parser with XML validation turned off.
  -    * @param rule an instance of <code>Rule</code↔ used for parsing the xml.
  +     * @param rule an instance of <code>RuleSet</code> used for parsing the xml.
        */
       public static Digester newDigester(RuleSet rule){
           return newDigester(false,false,rule);
  @@ -61,13 +66,11 @@
        * Create a <code>Digester</code> parser.
        * @param xmlValidation turn on/off xml validation
        * @param xmlNamespaceAware turn on/off namespace validation
  -     * @param rule an instance of <code>Rule</code↔ used for parsing the xml.
  +     * @param rule an instance of <code>RuleSet</code> used for parsing the xml.
        */
       public static Digester newDigester(boolean xmlValidation,
                                          boolean xmlNamespaceAware,
                                          RuleSet rule) {
  -
  -        URL url = null;
           Digester digester = new Digester();
           digester.setNamespaceAware(xmlNamespaceAware);
           digester.setValidating(xmlValidation);
  @@ -92,8 +95,9 @@
           registerLocalSchema();
           
           digester.setEntityResolver(schemaResolver);
  -        if ( rule != null )
  +        if ( rule != null ) {
               digester.addRuleSet(rule);
  +        }
   
           return (digester);
       }
  @@ -166,13 +170,16 @@
   
   
       /**
  -     * Load the resource and add it to the 
  +     * Load the resource and add it to the resolver.
        */
       protected static void register(String resourceURL, String resourcePublicId){
  -
           URL url = DigesterFactory.class.getResource(resourceURL);
  -        schemaResolver.register(resourcePublicId , url.toString() );
  -
  +   
  +        if(url == null) {
  +            log.warn("Could not get url for " + resourceURL);
  +        } else {
  +            schemaResolver.register(resourcePublicId , url.toString() );
  +        }
       }
   
   
  @@ -182,7 +189,12 @@
       protected static void turnOnValidation(Digester digester){
           URL url = DigesterFactory.class
                           .getResource(Constants.WebSchemaResourcePath_24);
  -        digester.setSchema(url.toString());     
  +  
  +        if(url == null) {
  +            log.error("Could not get url for " + 
Constants.WebSchemaResourcePath_24);
  +        } else {
  +            digester.setSchema(url.toString());     
  +        }
       }
   
   
  
  
  

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

Reply via email to