History | Log In     View a printable version of the current page. Get help!  
Issue Details (XML | Word)

Key: STS-278
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Tim Fennell
Reporter: Aaron Porter
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Stripes

NPE in BeforeAfterMethod

Created: 03/Oct/06 02:47 PM   Updated: 29/Oct/06 04:28 PM
Component/s: ActionBean Dispatching
Affects Version/s: Release 1.4.1
Fix Version/s: Release 1.4.2


 Description  « Hide
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;
+ }



 All   Comments   Change History      Sort Order:
Tim Fennell [14/Oct/06 07:14 AM]
Added the suggested guard.