Revision: 882
          http://stripes.svn.sourceforge.net/stripes/?rev=882&view=rev
Author:   bengunter
Date:     2008-04-07 06:54:33 -0700 (Mon, 07 Apr 2008)

Log Message:
-----------
Fix for STS-529. To avoid NPEs when looking for event handlers for ActionBean 
classes that are unknown to the ActionResolver, the map that holds the event 
mappings returns an empty map instead of null for any key that is not present 
in the map. In the end, the user will get a more informative message that says 
the default handler can't be located instead of an obscure NPE.

Modified Paths:
--------------
    
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java

Modified: 
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
===================================================================
--- 
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
      2008-04-01 18:01:19 UTC (rev 881)
+++ 
trunk/stripes/src/net/sourceforge/stripes/controller/AnnotatedClassActionResolver.java
      2008-04-07 13:54:33 UTC (rev 882)
@@ -33,6 +33,7 @@
 import java.lang.reflect.Modifier;
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -85,7 +86,16 @@
      * representing a subclass of ActionBean to a Map of event names to Method 
objects.
      */
     private Map<Class<? extends ActionBean>,Map<String,Method>> eventMappings =
-        new HashMap<Class<? extends ActionBean>,Map<String,Method>>();
+        new HashMap<Class<? extends ActionBean>,Map<String,Method>>() {
+        @Override
+        public Map<String, Method> get(Object key) {
+            Map<String, Method> value = super.get(key);
+            if (value == null)
+                return Collections.emptyMap();
+            else
+                return value;
+        }
+    };
 
     /**
      * Scans the classpath of the current classloader (not including parents) 
to find implementations


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Register now and save $200. Hurry, offer ends at 11:59 p.m., 
Monday, April 7! Use priority code J8TLD2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to