[Stripes-dev] [JIRA] Resolved: (STS-278) NPE in BeforeAfterMethod

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

[Stripes-dev] [JIRA] Resolved: (STS-278) NPE in BeforeAfterMethod

JIRA jira@mc4j.org
     [ http://mc4j.org/jira/browse/STS-278?page=all ]

Tim Fennell resolved STS-278.
-----------------------------

    Fix Version/s: Release 1.5
       Resolution: Fixed

Added the suggested guard.

> NPE in BeforeAfterMethod
> ------------------------
>
>                 Key: STS-278
>                 URL: http://mc4j.org/jira/browse/STS-278
>             Project: Stripes
>          Issue Type: Bug
>          Components: ActionBean Dispatching
>    Affects Versions: Release 1.4.1
>            Reporter: Aaron Porter
>         Assigned To: Tim Fennell
>             Fix For: Release 1.5
>
>
> If I have both the BeforeAfterMethodInterceptor and Nic's SecurityInterceptor specified in web.xml I get a NPE at BeforeAfterMethodInterceptor.java:111 because the return of context.getActionBean() isn't checked for null. The @Before handler directly above works correctly because it is checking for null.
> This fixes it:
> Index: BeforeAfterMethodInterceptor.java
> ===================================================================
> --- BeforeAfterMethodInterceptor.java   (revision 424)
> +++ BeforeAfterMethodInterceptor.java   (working copy)
> @@ -106,21 +106,23 @@
>          // Continue on and execute other filters and the lifecycle code
>          resolution = context.proceed();
> -        // Run After filter methods (if any)
> -        ActionBean bean = context.getActionBean();
> -               FilterMethods filterMethods = getFilterMethods(bean.getClass());
> -               List<Method> afterMethods = filterMethods.getAfterMethods(stage);
> +        // Run @After methods, as long as there's a bean to run them on
> +        if (context.getActionBean() != null) {
> +            ActionBean bean = context.getActionBean();
> +            FilterMethods filterMethods = getFilterMethods(bean.getClass());
> +            List<Method> afterMethods = filterMethods.getAfterMethods(stage);
> -        Resolution overrideResolution = null;
> -        for (Method method : afterMethods) {
> -            overrideResolution = invoke(bean, method, stage, After.class);
> -            if (overrideResolution != null) {
> -                return overrideResolution;
> +            Resolution overrideResolution = null;
> +            for (Method method : afterMethods) {
> +                overrideResolution = invoke(bean, method, stage, After.class);
> +                if (overrideResolution != null) {
> +                    return overrideResolution;
> +                }
>              }
>          }
> -               return resolution;
> -       }
> +        return resolution;
> +    }

--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://mc4j.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

       

-------------------------------------------------------------------------
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