Uploaded image for project: 'Wicket'
  1. Wicket
  2. WICKET-4370

HttpSession getSession() in MockHttpServletRequest is not compliant with the j2ee servlet spec

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 1.5.4
    • 1.5.5, 6.0.0-beta1
    • wicket
    • None

    Description

      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); }

      Attachments

        Activity

          People

            mgrigorov Martin Tzvetanov Grigorov
            giovanni.cuccu Giovanni Cuccu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: