[ 
http://www.stripesframework.org/jira/browse/STS-564?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=11384#action_11384
 ] 

Christian Poitras commented on STS-564:
---------------------------------------

This bug is linked to STS-540.
http://www.stripesframework.org/jira/browse/STS-540

> NullPointerException thrown when LocalizableError is added in event handler
> ---------------------------------------------------------------------------
>
>                 Key: STS-564
>                 URL: http://www.stripesframework.org/jira/browse/STS-564
>             Project: Stripes
>          Issue Type: Bug
>    Affects Versions: Release 1.5
>         Environment: Stripes revision 905
>            Reporter: Christian Poitras
>
> My event handler adds a LocalizableError to validation errors. When s:errors 
> is processing, no ActionBean is set in error resulting in a 
> NullPointerException.
> Code sample from my event handler.
>                 LocalizableError error = new 
> LocalizableError("newMascotFile.exists", mascotFile.getId());
>                 context.getValidationErrors().addGlobalError(error);
>                 logger.trace("end");
>                 return context.getSourcePageResolution();
> The problem seems to be in DispatchHelper. ValidationErrors are filled only 
> when handler returns null which is not desired since I want a page to be 
> shown with errors.
> In DispatchHelper.invokeEventHandler:
>             public Resolution intercept(ExecutionContext ctx) throws 
> Exception {
>                 Object returnValue = handler.invoke(bean);
>                 if (returnValue != null && returnValue instanceof Resolution) 
> {
>                     ctx.setResolutionFromHandler(true);
>                     return (Resolution) returnValue;
>                 }
>                 else if (returnValue != null) {
>                     log.warn("Expected handler method ", handler.getName(), " 
> on class ",
>                              bean.getClass().getSimpleName(), " to return a 
> Resolution. Instead it ",
>                              "returned: ", returnValue);
>                 }
>                 fillInValidationErrors(ctx);
>                 return null;
>             }
> fillInValidationErrors(ctx) is called only if resolution returned is null. It 
> should be 
>             public Resolution intercept(ExecutionContext ctx) throws 
> Exception {
>                 Object returnValue = handler.invoke(bean);
>                 fillInValidationErrors(ctx);
>                 if (returnValue != null && returnValue instanceof Resolution) 
> {
>                     ctx.setResolutionFromHandler(true);
>                     return (Resolution) returnValue;
>                 }
>                 else if (returnValue != null) {
>                     log.warn("Expected handler method ", handler.getName(), " 
> on class ",
>                              bean.getClass().getSimpleName(), " to return a 
> Resolution. Instead it ",
>                              "returned: ", returnValue);
>                 }
>                 return null;
>             }

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

        

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft 
Defy all challenges. Microsoft(R) Visual Studio 2008. 
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Stripes-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/stripes-development

Reply via email to