You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2004/09/03 16:47:26 UTC

DO NOT REPLY [Bug 31041] New: - [configuration] Invalid resource names in XMLConfiguration generate a NPE

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=31041>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=31041

[configuration] Invalid resource names in XMLConfiguration generate a NPE

           Summary: [configuration] Invalid resource names in
                    XMLConfiguration generate a NPE
           Product: Commons
           Version: Nightly Builds
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: Configuration
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: smanux@lfjr.net


XMLConfiguration throws a NullPointerException if an invalid resource name is
passed to its constructor, it should throw a ConfigurationException explaining
the issue instead.

Fix suggested by Ben Hutchison:

private static File resourceURLToFile(String resource) {
        URL confURL = XMLConfiguration.class.getClassLoader().getResource(resource);
        if (confURL == null) {
            confURL = ClassLoader.getSystemResource(resource);
        }
        if (confURL == null)
        	throw new IllegalArgumentException("Resource:"+resource+" not found
thru context or system classloaders.");
        return new File(confURL.getFile());
    }

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org