PrepareOperations.createActionContext does not detect existing context correctly
--------------------------------------------------------------------------------

                 Key: WW-3534
                 URL: https://issues.apache.org/jira/browse/WW-3534
             Project: Struts 2
          Issue Type: Bug
          Components: Dispatch Filter
    Affects Versions: 2.1.6
            Reporter: Jim Culbert


****The Problem****
In revision 768529 (current head revision) of 
/struts2/trunk/core/src/main/java/org/apache/struts2/dispatcher/ng/PrepareOperations.java
 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 map).

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 right". 

****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 is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to