[Stripes-dev] SF.net SVN: stripes: [441] trunk/stripes/src/net/sourceforge/stripes/ controller/BeforeAfterMethodInterceptor.java

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Stripes-dev] SF.net SVN: stripes: [441] trunk/stripes/src/net/sourceforge/stripes/ controller/BeforeAfterMethodInterceptor.java

tfenne
Revision: 441
          http://svn.sourceforge.net/stripes/?rev=441&view=rev
Author:   tfenne
Date:     2006-10-14 07:26:20 -0700 (Sat, 14 Oct 2006)

Log Message:
-----------
Fix for STS-278: NPE in BeforeAfterMethodInterceptor when ActionBeanResolution doesn't result in an action bean being placed in the execution context.

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

Modified: trunk/stripes/src/net/sourceforge/stripes/controller/BeforeAfterMethodInterceptor.java
===================================================================
--- trunk/stripes/src/net/sourceforge/stripes/controller/BeforeAfterMethodInterceptor.java 2006-10-14 13:46:10 UTC (rev 440)
+++ trunk/stripes/src/net/sourceforge/stripes/controller/BeforeAfterMethodInterceptor.java 2006-10-14 14:26:20 UTC (rev 441)
@@ -114,26 +114,28 @@
         resolution = context.proceed();
 
         // Run After filter methods (if any)
-        ActionBean bean = context.getActionBean();
-        FilterMethods filterMethods = getFilterMethods(bean.getClass());
- List<Method> afterMethods = filterMethods.getAfterMethods(stage);
+        if (context.getActionBean() != null) {
+            ActionBean bean = context.getActionBean();
+            FilterMethods filterMethods = getFilterMethods(bean.getClass());
+            List<Method> afterMethods = filterMethods.getAfterMethods(stage);
 
-        // Re-get the event name in case we're executing after handler resolution
-        // in which case the name will have been null before, and non-null now
-        event = abc == null ? null : abc.getEventName();
+            // Re-get the event name in case we're executing after handler resolution
+            // in which case the name will have been null before, and non-null now
+            event = abc == null ? null : abc.getEventName();
 
-        Resolution overrideResolution = null;
-        for (Method method : afterMethods) {
-            String[] on = method.getAnnotation(After.class).on();
-            if (event == null || CollectionUtil.applies(on, event)) {
-                overrideResolution = invoke(bean, method, stage, After.class);
-                if (overrideResolution != null) {
-                    return overrideResolution;
+            Resolution overrideResolution = null;
+            for (Method method : afterMethods) {
+                String[] on = method.getAnnotation(After.class).on();
+                if (event == null || CollectionUtil.applies(on, event)) {
+                    overrideResolution = invoke(bean, method, stage, After.class);
+                    if (overrideResolution != null) {
+                        return overrideResolution;
+                    }
                 }
             }
         }
-
- return resolution;
+        
+        return resolution;
  }
 
     /**


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

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Stripes-development mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/stripes-development