You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Lukasz Lenart (JIRA)" <ji...@apache.org> on 2013/05/23 12:43:20 UTC

[jira] [Updated] (WW-4052) "params" attribute in ExceptionMapping not propagated during exception handling

     [ https://issues.apache.org/jira/browse/WW-4052?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Lukasz Lenart updated WW-4052:
------------------------------

    Description: 
I am using the convention plugin to configure ExceptionMappings for my action.
Example:

{code:java}
exceptionMappings = {@ExceptionMapping(exception = "xxx.core.SCFServiceException", result = "scfHome" , params = {"errorMessage", "scf.svc.exception", "operationName", SCFHelper.FACILITY_OVERVIEW})
{code}

In the exception case, "errorMessage" and "operationName" are not propagated to the action mapped to "scfHome". 

It turns out that the method "getParams" from ExceptionMappingConfig has no callers after its construction, so this feature never worked or was broken before version 2.3.8.

Patch below. Tested using the convention plugin.

{noformat}
22a23
> import java.util.HashMap;
23a25
> import java.util.Map;
193,195c195,200
<             String mappedResult = this.findResultFromExceptions(exceptionMappings, e);
<             if (mappedResult != null) {
<                 result = mappedResult;
---
>             ExceptionMappingConfig mappingConfig = this.findMappingFromExceptions(exceptionMappings, e);
>             if (mappingConfig != null && mappingConfig.getResult()!=null) {
>                 Map parameterMap = mappingConfig.getParams();
>                 // create a mutable HashMap since some interceptors will remove parameters, and parameterMap is immutable
>                 invocation.getInvocationContext().setParameters(new HashMap(parameterMap));
>                 result = mappingConfig.getResult();
252c257,262
<         String result = null;
---
>     	ExceptionMappingConfig result = findMappingFromExceptions(exceptionMappings, t);
>         return result==null?null:result.getResult();
>     }
> 
>     protected ExceptionMappingConfig findMappingFromExceptions(List<ExceptionMappingConfig> exceptionMappings, Throwable t) {
>     	ExceptionMappingConfig result = null;
262c272
<                     result = exceptionMappingConfig.getResult();
---
>                     result = exceptionMappingConfig;
{nofotmat}

  was:
I am using the convention plugin to configure ExceptionMappings for my action.
Example:

exceptionMappings = {@ExceptionMapping(exception = "xxx.core.SCFServiceException", result = "scfHome" , params = {"errorMessage", "scf.svc.exception", "operationName", SCFHelper.FACILITY_OVERVIEW})

In the exception case, "errorMessage" and "operationName" are not propagated to the action mapped to "scfHome". 

It turns out that the method "getParams" from ExceptionMappingConfig has no callers after its construction, so this feature never worked or was broken before version 2.3.8.

Patch below. Tested using the convention plugin.

22a23
> import java.util.HashMap;
23a25
> import java.util.Map;
193,195c195,200
<             String mappedResult = this.findResultFromExceptions(exceptionMappings, e);
<             if (mappedResult != null) {
<                 result = mappedResult;
---
>             ExceptionMappingConfig mappingConfig = this.findMappingFromExceptions(exceptionMappings, e);
>             if (mappingConfig != null && mappingConfig.getResult()!=null) {
>                 Map parameterMap = mappingConfig.getParams();
>                 // create a mutable HashMap since some interceptors will remove parameters, and parameterMap is immutable
>                 invocation.getInvocationContext().setParameters(new HashMap(parameterMap));
>                 result = mappingConfig.getResult();
252c257,262
<         String result = null;
---
>     	ExceptionMappingConfig result = findMappingFromExceptions(exceptionMappings, t);
>         return result==null?null:result.getResult();
>     }
> 
>     protected ExceptionMappingConfig findMappingFromExceptions(List<ExceptionMappingConfig> exceptionMappings, Throwable t) {
>     	ExceptionMappingConfig result = null;
262c272
<                     result = exceptionMappingConfig.getResult();
---
>                     result = exceptionMappingConfig;




    
> "params" attribute in ExceptionMapping not propagated during exception handling
> -------------------------------------------------------------------------------
>
>                 Key: WW-4052
>                 URL: https://issues.apache.org/jira/browse/WW-4052
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>    Affects Versions: 2.3.14
>         Environment: Any
>            Reporter: Stefan Reich
>             Fix For: 2.3.15
>
>         Attachments: ExceptionMappingInterceptor.patch
>
>
> I am using the convention plugin to configure ExceptionMappings for my action.
> Example:
> {code:java}
> exceptionMappings = {@ExceptionMapping(exception = "xxx.core.SCFServiceException", result = "scfHome" , params = {"errorMessage", "scf.svc.exception", "operationName", SCFHelper.FACILITY_OVERVIEW})
> {code}
> In the exception case, "errorMessage" and "operationName" are not propagated to the action mapped to "scfHome". 
> It turns out that the method "getParams" from ExceptionMappingConfig has no callers after its construction, so this feature never worked or was broken before version 2.3.8.
> Patch below. Tested using the convention plugin.
> {noformat}
> 22a23
> > import java.util.HashMap;
> 23a25
> > import java.util.Map;
> 193,195c195,200
> <             String mappedResult = this.findResultFromExceptions(exceptionMappings, e);
> <             if (mappedResult != null) {
> <                 result = mappedResult;
> ---
> >             ExceptionMappingConfig mappingConfig = this.findMappingFromExceptions(exceptionMappings, e);
> >             if (mappingConfig != null && mappingConfig.getResult()!=null) {
> >                 Map parameterMap = mappingConfig.getParams();
> >                 // create a mutable HashMap since some interceptors will remove parameters, and parameterMap is immutable
> >                 invocation.getInvocationContext().setParameters(new HashMap(parameterMap));
> >                 result = mappingConfig.getResult();
> 252c257,262
> <         String result = null;
> ---
> >     	ExceptionMappingConfig result = findMappingFromExceptions(exceptionMappings, t);
> >         return result==null?null:result.getResult();
> >     }
> > 
> >     protected ExceptionMappingConfig findMappingFromExceptions(List<ExceptionMappingConfig> exceptionMappings, Throwable t) {
> >     	ExceptionMappingConfig result = null;
> 262c272
> <                     result = exceptionMappingConfig.getResult();
> ---
> >                     result = exceptionMappingConfig;
> {nofotmat}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira