Bug 30636 - NullPointerException in DigesterFactory
Summary: NullPointerException in DigesterFactory
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 5.0.27
Hardware: Other other
: P3 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-08-12 21:00 UTC by Rob Grzywinski
Modified: 2004-11-16 19:05 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Rob Grzywinski 2004-08-12 21:00:17 UTC
A misconfigured server will cause the following:

java.lang.NullPointerException
	at org.apache.catalina.startup.DigesterFactory.register
(DigesterFactory.java:174)
	at org.apache.catalina.startup.DigesterFactory.registerLocalSchema
(DigesterFactory.java:139)
	at org.apache.catalina.startup.DigesterFactory.newDigester
(DigesterFactory.java:92)
	at org.apache.catalina.startup.ContextConfig.createWebXmlDigester
(ContextConfig.java:435)
        ...

The defect occurs because a resource is loaded from the ClassLoader and is 
never checked for null.  Lines 173 - 174 of 
org.apache.catalina.startup.DigesterFactory should be changed to:

        URL url = DigesterFactory.class.getResource(resourceURL);
        if(url == null)
            throw new WhateverIsAnAppropriateException(<"The resource 
identified by \"" + resourceURL + "\" does not exist.">);
        /* else -- the URL for the resource exists */
        schemaResolver.register(resourcePublicId , url.toString() );

where the text in <>'s is replaced with the appropriate resource bundle 
mechanism.

I would recommend that a code audit is performed to determine other such uses 
of getResource(), getResourceAsStream(), etc without appropriate null checks to 
ensure a consistent and pleasant user experience.
Comment 1 Yoav Shapira 2004-09-02 14:28:11 UTC
Added Log and NPE checking to DigesterFactory.  Thanks.