struts-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Michael Hintenaus (JIRA)" <j...@apache.org>
Subject [jira] [Comment Edited] (WW-4921) NPE in I18nInterceptor$SessionLocaleHandler.read
Date Thu, 22 Feb 2018 07:17:00 GMT

    [ https://issues.apache.org/jira/browse/WW-4921?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16372464#comment-16372464
] 

Michael Hintenaus edited comment on WW-4921 at 2/22/18 7:16 AM:
----------------------------------------------------------------

No session is no alternative for me. Setting a Map is my workaround (see below).

But as mentioned by [~yasser.zamani] : StrutsTestCase has a {{initActionContext}} Method
(which sets the map automatically), StrutsJUnit4TestCase has not such a method - why?
{code:java}
 @Override
    protected ActionProxy getActionProxy(final String uri) {
        final ActionProxy proxy = super.getActionProxy(uri);
        final ActionContext context = proxy.getInvocation().getInvocationContext();
        if (context.getSession() == null) {
            context.setSession(new SessionMap<>(request));          
 
        }
        return proxy;
    }{code}


was (Author: michael hintenaus):
No session is no alternative for me. Setting a Map is my workaround (see below).

But as mentioned by [~yasser.zamani] : StrutsTestCase has a {{initActionContext}} Method
(which set the map automatically), StrutsJUnit4TestCase has not such a method - why?
{code:java}
 @Override
    protected ActionProxy getActionProxy(final String uri) {
        final ActionProxy proxy = super.getActionProxy(uri);
        final ActionContext context = proxy.getInvocation().getInvocationContext();
        if (context.getSession() == null) {
            context.setSession(new SessionMap<>(request));          
 
        }
        return proxy;
    }{code}

> NPE in I18nInterceptor$SessionLocaleHandler.read
> ------------------------------------------------
>
>                 Key: WW-4921
>                 URL: https://issues.apache.org/jira/browse/WW-4921
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Interceptors
>            Reporter: Michael Hintenaus
>            Priority: Major
>              Labels: test
>             Fix For: 2.5.16
>
>
> Calling
> {code:java}
> getActionProxy("/index.action").getInvocation().invoke(){code}
> in a TestCase which extends from StrutsJUnit4TestCase will lead to a NullPointerException.
> Overriding getActionProxy like this will help:
> {code:java}
>  @Override
>     protected ActionProxy getActionProxy(final String uri) {
>         final ActionProxy proxy = super.getActionProxy(uri);
>         final ActionContext context = proxy.getInvocation().getInvocationContext();
>         if (context.getSession() == null) {
>             context.setSession(new SessionMap<>(request));      
     
>         }
>         return proxy;
>     }{code}
>  



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message