Uploaded image for project: 'WildFly'
  1. WildFly
  2. WFLY-14118

Distributed session manager can throw UnsupportedOperationException on concurrent calls to HttpServletRequest.getSession(...) for a given session

    XMLWordPrintable

Details

    • Workaround Exists
    • Hide

      Include a servlet extension in the deployment that installs a SessionManager decorator that serializes calls to SessionManager.getSession(...), e.g.

      @MetaInfServices(ServletExtension.class)
      public class TempServletExtension implements ServletExtension {
      
          @Override
          public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) {
              SessionManagerFactory factory = deploymentInfo.getSessionManagerFactory();
              deploymentInfo.setSessionManagerFactory(new SessionManagerFactory() {
                  @Override
                  public SessionManager createSessionManager(Deployment deployment) {
                      SessionManager manager = factory.createSessionManager(deployment);
                      return new SessionManager() {
                          @Override
                          public String getDeploymentName() {
                              return manager.getDeploymentName();
                          }
      
                          @Override
                          public void start() {
                              manager.start();
                          }
      
                          @Override
                          public void stop() {
                              manager.stop();
                          }
      
                          @Override
                          public Session createSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig) {
                              return manager.createSession(serverExchange, sessionCookieConfig);
                          }
      
                          @Override
                          public synchronized Session getSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig) {
                              return manager.getSession(serverExchange, sessionCookieConfig);
                          }
      
                          @Override
                          public Session getSession(String sessionId) {
                              return manager.getSession(sessionId);
                          }
      
                          @Override
                          public void registerSessionListener(SessionListener listener) {
                              manager.registerSessionListener(listener);
                          }
      
                          @Override
                          public void removeSessionListener(SessionListener listener) {
                              manager.removeSessionListener(listener);
                          }
      
                          @Override
                          public void setDefaultSessionTimeout(int timeout) {
                              manager.setDefaultSessionTimeout(timeout);
                          }
      
                          @Override
                          public Set<String> getTransientSessions() {
                              return manager.getTransientSessions();
                          }
      
                          @Override
                          public Set<String> getActiveSessions() {
                              return manager.getActiveSessions();
                          }
      
                          @Override
                          public Set<String> getAllSessions() {
                              return manager.getAllSessions();
                          }
      
                          @Override
                          public SessionManagerStatistics getStatistics() {
                              return manager.getStatistics();
                          }
                      };
                  }
              });
          }
      }
      
      
      Show
      Include a servlet extension in the deployment that installs a SessionManager decorator that serializes calls to SessionManager.getSession(...), e.g. @MetaInfServices(ServletExtension.class) public class TempServletExtension implements ServletExtension { @Override public void handleDeployment(DeploymentInfo deploymentInfo, ServletContext servletContext) { SessionManagerFactory factory = deploymentInfo.getSessionManagerFactory(); deploymentInfo.setSessionManagerFactory( new SessionManagerFactory() { @Override public SessionManager createSessionManager(Deployment deployment) { SessionManager manager = factory.createSessionManager(deployment); return new SessionManager() { @Override public String getDeploymentName() { return manager.getDeploymentName(); } @Override public void start() { manager.start(); } @Override public void stop() { manager.stop(); } @Override public Session createSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig) { return manager.createSession(serverExchange, sessionCookieConfig); } @Override public synchronized Session getSession(HttpServerExchange serverExchange, SessionConfig sessionCookieConfig) { return manager.getSession(serverExchange, sessionCookieConfig); } @Override public Session getSession( String sessionId) { return manager.getSession(sessionId); } @Override public void registerSessionListener(SessionListener listener) { manager.registerSessionListener(listener); } @Override public void removeSessionListener(SessionListener listener) { manager.removeSessionListener(listener); } @Override public void setDefaultSessionTimeout( int timeout) { manager.setDefaultSessionTimeout(timeout); } @Override public Set< String > getTransientSessions() { return manager.getTransientSessions(); } @Override public Set< String > getActiveSessions() { return manager.getActiveSessions(); } @Override public Set< String > getAllSessions() { return manager.getAllSessions(); } @Override public SessionManagerStatistics getStatistics() { return manager.getStatistics(); } }; } }); } }
    • ---
    • ---

    Description

      19:15:26,603 ERROR [io.undertow.servlet.request] (default task-3) UT015005: Error invoking method requestInitialized on listener class org.jboss.weld.module.web.servlet.WeldInitialListener: java.lang.UnsupportedOperationException
          at java.base/java.util.AbstractMap$SimpleImmutableEntry.setValue(AbstractMap.java:794)
          at org.wildfly.clustering.ee.cache@21.0.1.Final//org.wildfly.clustering.ee.cache.ConcurrentManager.apply(ConcurrentManager.java:88)
          at org.wildfly.clustering.web.cache@21.0.1.Final//org.wildfly.clustering.web.cache.session.ConcurrentSessionManager.findSession(ConcurrentSessionManager.java:70)
          at org.wildfly.clustering.web.undertow@21.0.1.Final//org.wildfly.clustering.web.undertow.session.DistributableSessionManager.getSession(DistributableSessionManager.java:227)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.spec.ServletContextImpl.getSession(ServletContextImpl.java:858)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.spec.HttpServletRequestImpl.getSession(HttpServletRequestImpl.java:421)
          at org.jboss.weld.core@3.1.5.Final//org.jboss.weld.module.web.servlet.SessionHolder.requestInitialized(SessionHolder.java:47)
          at org.jboss.weld.core@3.1.5.Final//org.jboss.weld.module.web.servlet.HttpContextLifecycle.requestInitialized(HttpContextLifecycle.java:247)
          at org.jboss.weld.core@3.1.5.Final//org.jboss.weld.module.web.servlet.WeldInitialListener.requestInitialized(WeldInitialListener.java:146)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ApplicationListeners.requestInitialized(ApplicationListeners.java:263)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:268)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler.access$100(ServletInitialHandler.java:78)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:133)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler$2.call(ServletInitialHandler.java:130)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ServletRequestContextThreadSetupAction$1.call(ServletRequestContextThreadSetupAction.java:48)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.core.ContextClassLoaderSetupAction$1.call(ContextClassLoaderSetupAction.java:43)
          at org.wildfly.extension.undertow@21.0.1.Final//org.wildfly.extension.undertow.security.SecurityContextThreadSetupAction.lambda$create$0(SecurityContextThreadSetupAction.java:105)
          at org.wildfly.extension.undertow@21.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
          at org.wildfly.extension.undertow@21.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
          at org.wildfly.extension.undertow@21.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
          at org.wildfly.extension.undertow@21.0.1.Final//org.wildfly.extension.undertow.deployment.UndertowDeploymentInfoService$UndertowThreadSetupAction.lambda$create$0(UndertowDeploymentInfoService.java:1530)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:249)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:78)
          at io.undertow.servlet@2.2.2.Final//io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:99)
          at io.undertow.core@2.2.2.Final//io.undertow.server.Connectors.executeRootHandler(Connectors.java:387)
          at io.undertow.core@2.2.2.Final//io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:841)
          at org.jboss.threads@2.4.0.Final//org.jboss.threads.ContextClassLoaderSavingRunnable.run(ContextClassLoaderSavingRunnable.java:35)
          at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor.safeRun(EnhancedQueueExecutor.java:1990)
          at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.doRunTask(EnhancedQueueExecutor.java:1486)
          at org.jboss.threads@2.4.0.Final//org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1348)
          at org.jboss.xnio@3.8.2.Final//org.xnio.XnioWorker$WorkerThreadFactory$1$1.run(XnioWorker.java:1280)
          at java.base/java.lang.Thread.run(Thread.java:834)
      

      Attachments

        Issue Links

          Activity

            People

              pferraro@redhat.com Paul Ferraro
              pferraro@redhat.com Paul Ferraro
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: