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

Leonardo D'Alimonte commented on WICKET-4370:
---------------------------------------------

Hi everybody,
I'm migrating to Wicket 1.5.9 and I found this code inside 
MockHttpServletRequest.getSession(boolean):
                HttpSession sess = null;
                if (session instanceof MockHttpSession)
                {
                        MockHttpSession mockHttpSession = (MockHttpSession) 
session;
                        if (b)
                        {
                                mockHttpSession.setTemporary(false);
                        }

                        if (mockHttpSession.isTemporary() == false)
                        {
                                sess = session;
                        }
                }
                return sess;

At the moment, passing "false" will never allow you to get the session, even if 
it actually exists.
Is it possible I'm doing something wrong in my code?

Thanks in advance!

                
> HttpSession getSession() in MockHttpServletRequest is not compliant with the 
> j2ee servlet spec
> ----------------------------------------------------------------------------------------------
>
>                 Key: WICKET-4370
>                 URL: https://issues.apache.org/jira/browse/WICKET-4370
>             Project: Wicket
>          Issue Type: Bug
>          Components: wicket
>    Affects Versions: 1.5.4
>            Reporter: Giovanni Cuccu
>            Assignee: Martin Grigorov
>            Priority: Minor
>             Fix For: 1.5.5, 6.0.0-beta1
>
>
> The implementation of
> httpRequest.getSession();
> for MockHttpServletRequest seems not correct since it can return null when
> the servler api specs
> (http://docs.oracle.com/javaee/1.4/api/) says:
> public HttpSession getSession()
> Returns the current session associated with this request, or if the request
> does not have a session, creates one.
> So as far as I understand
> httpRequest.getSession(); and httpRequest.getSession(true); are equivalent
> The MockHttpServletRequest implementation is
>    public HttpSession getSession()
>    {
>        if (session instanceof MockHttpSession &&
> ((MockHttpSession)session).isTemporary())
>        {
>            return null;
>        }
>        return session;
>    }
> I think it should be 
>    public HttpSession getSession()
>    {
>        return getSession(true);
>    }

--
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

Reply via email to