struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Lukasz Lenart (JIRA)" <>
Subject [jira] [Commented] (WW-3534) PrepareOperations.createActionContext does not detect existing context correctly
Date Sun, 23 Apr 2017 09:29:04 GMT


Lukasz Lenart commented on WW-3534:

Marking with 2.6 label just to add this as a one of potential refactors of the ActionContext

> PrepareOperations.createActionContext does not detect existing context correctly
> --------------------------------------------------------------------------------
>                 Key: WW-3534
>                 URL:
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Dispatch Filter
>    Affects Versions: 2.1.6
>            Reporter: Jim Culbert
>             Fix For: 2.6
> ****The Problem****
> In revision 768529 (current head revision) of /struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/
at lines 72-73, there is a logic error. 
> ActionContext.getContext will never return null, it always returns a context object (when
no context has been created in the thread, action ActionContext.getContext() casts an empty
map to an ActionContext object when it returns, so, even thoughg no initialization has been
done, the getContext method still returns a non-null object that contains an empty context
> The implication of this is that, when the StrutsPrepareAndExecuteFilter (and presumably
the StrutsPrepareFilter) runs, execution never follows the code branch which is designed to
initialize the value stack.
> I think the reason this does not cause more problems is that there seems to be defensive
code in a lot of places that initializes the valuestack/actioncontext if things don't "look
> ****Where I saw the problem****
> In my use case, I initialize the locale in the action context (scriptlet in the view
jsp...)  prior to using any <s:text> tag. When I do use a tag, the text helper code
detects that there is no value stack and creates a new actioncontext (thus blowing away the
locale setting that I had established). The result is that regardless of what I set the locale
to, the tags always rendered in the default locale. Hack was to use any tag that manipulates
the value stack before setting the locale but, this obviously needs to be fixed...

This message was sent by Atlassian JIRA

View raw message