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

NPE in ServletContextImpl after session timed out

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major 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) ...

      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.

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

              Created:
              Updated:
              Resolved: