stephenc commented on a change in pull request #34:
URL: https://github.com/apache/openwebbeans/pull/34#discussion_r632492164



##########
File path: 
webbeans-web/src/main/java/org/apache/webbeans/web/context/WebContextsService.java
##########
@@ -593,9 +593,17 @@ protected boolean sessionIsExpiring(HttpSession session)
         int maxInactiveInterval = session.getMaxInactiveInterval();
         if (maxInactiveInterval > 0)
         {
-            long inactiveSince = 
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - 
session.getLastAccessedTime());
-            if (inactiveSince >= maxInactiveInterval)
+            try 
             {
+                long inactiveSince = 
TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis() - 
session.getLastAccessedTime());
+                if (inactiveSince >= maxInactiveInterval)
+                {
+                    return true;
+                }
+            }
+            catch (IllegalStateException e) 
+            {
+                // Jetty will throw an ISE if you attempt to query the last 
accessed time of a session that is being invalidated
                 return true;

Review comment:
       I can confirm that:
   
   ```java
   public class JettyBugWorkaroundWebContextService extends WebContextsService {
       public JettyBugWorkaroundWebContextService(WebBeansContext 
webBeansContext) {
           super(webBeansContext);
       }
   
       @Override
       protected boolean sessionIsExpiring(HttpSession session) {
           try {
               return super.sessionIsExpiring(session);
           } catch (IllegalStateException e) {
               if ("Session not valid".equals(e.getMessage())) {
                   return true;
               }
               throw e;
           }
       }
   }
   ```
   
   coupled with an openwebbeans.properties, e.g.
   
   ```
   configuration.ordinal=15
   
org.apache.webbeans.spi.ContextsService=...JettyBugWorkaroundWebContextService
   ```
   
   Works around the issue and would be trivial to add to the owb-jetty9 module




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to