Uploaded image for project: 'Undertow'
  1. Undertow
  2. UNDERTOW-2141

NPE in ServletContextImpl after session timed out

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 2.3.0.Final, 2.2.21.Final
    • 2.0.0.Final, 2.1.0.Final, 2.2.0.Final, 2.2.5.Final, 2.3.0.Beta1
    • Servlet
    • None
    • Hide

       * create deployment with session servlet
       * deploy and start
       * create another deployment with session servlet and broken session manager factory
       * deploy, which will fail, ignore the exception
         (this is Wildfly behaviour when deploying an EAR containing multiple WARs)
       * send a request to first session servlet (this will create a new session)
         Undertow responds with HTTP 200
       * wait until session expires
       * send another request to the first session servlet
         Undertow responds with HTTP 500

      The following stacktrace shows up in the log

      ERROR (XNIO-1 task-2) [io.undertow.request] <LoggingExceptionHandler.java:80> UT005023: Exception handling request to /1/servlet: java.lang.NullPointerException: Cannot invoke "io.undertow.server.session.SessionManager.getSession(String)" because the return value of "io.undertow.servlet.api.Deployment.getSessionManager()" is null
      at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:937)
      at io.undertow.servlet.spec.HttpServletRequestImpl.getSession(HttpServletRequestImpl.java:443)
      at io.undertow.servlet.spec.HttpServletRequestImpl.getSession(HttpServletRequestImpl.java:448)
      at io.undertow.servlet.test.session.SessionServlet.doGet(SessionServlet.java:37)
      at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:527)
      ...
      
      Show
       * create deployment with session servlet  * deploy and start  * create another deployment with session servlet and broken session manager factory  * deploy, which will fail, ignore the exception    (this is Wildfly behaviour when deploying an EAR containing multiple WARs)  * send a request to first session servlet (this will create a new session)    Undertow responds with HTTP 200  * wait until session expires  * send another request to the first session servlet    Undertow responds with HTTP 500 The following stacktrace shows up in the log ERROR (XNIO-1 task-2) [io.undertow.request] <LoggingExceptionHandler.java:80> UT005023: Exception handling request to /1/servlet: java.lang.NullPointerException: Cannot invoke "io.undertow.server.session.SessionManager.getSession( String )" because the return value of "io.undertow.servlet.api.Deployment.getSessionManager()" is null at io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:937) at io.undertow.servlet.spec.HttpServletRequestImpl.getSession(HttpServletRequestImpl.java:443) at io.undertow.servlet.spec.HttpServletRequestImpl.getSession(HttpServletRequestImpl.java:448) at io.undertow.servlet.test.session.SessionServlet.doGet(SessionServlet.java:37) at jakarta.servlet.http.HttpServlet.service(HttpServlet.java:527) ...

    Description

      In a servlet container with multiple deployments where at least one deployment did not deploy successfully Undertow responds with HTTP 500 after session expired.

      I've created a test case and a fix. PR will come soon.

      Attachments

        Issue Links

          Activity

            People

              flaviarnn Flavia Rainone
              wal-jan Jan Walkotte (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: