[jira] Closed: (NANO-58) NullPointerException on nonexistent classpath scripts

jira-yCVjj/[email protected] Fri, 26 Mar 2004 05:06:35 -0500 (EST)
Newsgroups gmane.comp.java.nanocontainer.devel
Message-ID <[email protected]>
Message:

   The following issue has been closed.

---------------------------------------------------------------------
View the issue:
  http://jira.codehaus.org/secure/ViewIssue.jspa?key=NANO-58

Here is an overview of the issue:
---------------------------------------------------------------------
        Key: NANO-58
    Summary: NullPointerException on nonexistent classpath scripts
       Type: Bug

     Status: Closed
   Priority: Major
 Resolution: FIXED

 Original Estimate: Unknown
 Time Spent: Unknown
  Remaining: Unknown

    Project: NanoContainer
 Components: 
             nanoweb
   Fix Fors:
             1.0-beta-1

   Assignee: Aslak Hellesoy
   Reporter: Miguel A Paraz

    Created: Thu, 25 Mar 2004 8:00 PM
    Updated: Fri, 26 Mar 2004 5:05 AM

Description:
This trivial patch will check if getResource() fails for a nonexistent  script in the classpath.


--- NanoWebServlet.java	21 Mar 2004 16:11:18 -0000	1.1
+++ NanoWebServlet.java	26 Mar 2004 00:53:37 -0000
@@ -92,10 +92,14 @@
 
     private Object getScriptAction(String key, MutablePicoContainer container) throws SyntaxException, IOException {
         URL scriptURL = getClass().getResource(key);
-        Class scriptClass = cachingScriptClassLoader.getClass(scriptURL);
-        container.registerComponentImplementation(key, scriptClass);
-        Object result = container.getComponentInstance(key);
-        return result;
+        if (scriptURL == null) {
+            return null;
+        } else {
+            Class scriptClass = cachingScriptClassLoader.getClass(scriptURL);
+            container.registerComponentImplementation(key, scriptClass);
+            Object result = container.getComponentInstance(key);
+            return result;
+        }
     }
 
     private void setPropertiesWithOgnl(HttpServletRequest servletRequest, Object action) throws ServletException {



---------------------------------------------------------------------
JIRA INFORMATION:
This message is automatically generated by JIRA.

If you think it was sent incorrectly contact one of the administrators:
   http://jira.codehaus.org/secure/Administrators.jspa

If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira