[ https://issues.apache.org/jira/browse/WW-5087?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Brian Lenz updated WW-5087:
---------------------------
Description:
As I reported on the mailing list, there is a bug with {{AliasInterceptor}} not handling
the {{Parameter.Empty}} that is returned from {{HttpParameters.get()}}. Since {{HttpParameters.get()}} always
returns a non-null value, the {{Evaluated}} object is treated as always being defined, which
results in the empty value being set incorrectly on the stack.
The bug was originally introduced here:
https://github.com/apache/struts/commit/787f2f96eb9f1bb3c8012ab42aa222ae6286a91a#diff-b7b7c87c1012088e79dcc5a7bd9e8127R168
The fix is easy; this code:
{code:java}
// workaround
HttpParameters contextParameters = ActionContext.getContext().getParameters();
if (null != contextParameters) {
value = new Evaluated(contextParameters.get(name));
}{code}
needs to be updated to:
{code:java}
// workaround
HttpParameters contextParameters = ActionContext.getContext().getParameters();
if (null != contextParameters) {
Parameter param = contextParameters.get(name);
value = new Evaluated(param.isDefined() ? param : null);
} {code}
This way, it ensures the {{Evaluated}} value is only defined when appropriate.
was:
As I reported on the mailing list, there is a bug with {{AliasInterceptor}} not handling
the {{Parameter.Empty}} that is returned from {{HttpParameters.get()}}. Since {{HttpParameters.get()}} always
returns a non-null value, the {{Evaluated}} object is treated as always being defined, which
results in the empty value being set incorrectly on the stack.
The fix is easy; this code:
{code:java}
// workaround
HttpParameters contextParameters = ActionContext.getContext().getParameters();
if (null != contextParameters) {
value = new Evaluated(contextParameters.get(name));
}{code}
needs to be updated to:
{code:java}
// workaround
HttpParameters contextParameters = ActionContext.getContext().getParameters();
if (null != contextParameters) {
Parameter param = contextParameters.get(name);
value = new Evaluated(param.isDefined() ? param : null);
} {code}
This way, it ensures the {{Evaluated}} value is only defined when appropriate.
> AliasInterceptor doesn't properly handle Parameter.Empty
> --------------------------------------------------------
>
> Key: WW-5087
> URL: https://issues.apache.org/jira/browse/WW-5087
> Project: Struts 2
> Issue Type: Bug
> Components: Core Interceptors
> Affects Versions: 2.5.22
> Reporter: Brian Lenz
> Priority: Major
>
> As I reported on the mailing list, there is a bug with {{AliasInterceptor}} not handling
the {{Parameter.Empty}} that is returned from {{HttpParameters.get()}}. Since {{HttpParameters.get()}} always
returns a non-null value, the {{Evaluated}} object is treated as always being defined, which
results in the empty value being set incorrectly on the stack.
> The bug was originally introduced here:
> https://github.com/apache/struts/commit/787f2f96eb9f1bb3c8012ab42aa222ae6286a91a#diff-b7b7c87c1012088e79dcc5a7bd9e8127R168
> The fix is easy; this code:
> {code:java}
> // workaround
> HttpParameters contextParameters = ActionContext.getContext().getParameters();
> if (null != contextParameters) {
> value = new Evaluated(contextParameters.get(name));
> }{code}
> needs to be updated to:
> {code:java}
> // workaround
> HttpParameters contextParameters = ActionContext.getContext().getParameters();
> if (null != contextParameters) {
> Parameter param = contextParameters.get(name);
> value = new Evaluated(param.isDefined() ? param : null);
> } {code}
> This way, it ensures the {{Evaluated}} value is only defined when appropriate.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
|