[jboss-cvs] JBossAS SVN: r58088 - branches/JBoss_4_0_3_SP1_JBAS-3814/tomcat/src/main/org/jboss/web/tomcat/tc5/session

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Fri Nov 3 15:09:45 EST 2006


Author: bstansberry at jboss.com
Date: 2006-11-03 15:09:44 -0500 (Fri, 03 Nov 2006)
New Revision: 58088

Modified:
   branches/JBoss_4_0_3_SP1_JBAS-3814/tomcat/src/main/org/jboss/web/tomcat/tc5/session/ClusteredSession.java
   branches/JBoss_4_0_3_SP1_JBAS-3814/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java
Log:
[JBAS-3814] Port of fix for "JBAS-2403 JBossCacheManager session expiration algorithm ignores replication events"

Modified: branches/JBoss_4_0_3_SP1_JBAS-3814/tomcat/src/main/org/jboss/web/tomcat/tc5/session/ClusteredSession.java
===================================================================
--- branches/JBoss_4_0_3_SP1_JBAS-3814/tomcat/src/main/org/jboss/web/tomcat/tc5/session/ClusteredSession.java	2006-11-03 19:55:35 UTC (rev 58087)
+++ branches/JBoss_4_0_3_SP1_JBAS-3814/tomcat/src/main/org/jboss/web/tomcat/tc5/session/ClusteredSession.java	2006-11-03 20:09:44 UTC (rev 58088)
@@ -332,7 +332,59 @@
      boolean expireLocally = false;
      expire(notify, expireLocally);
    }
+   
+  
+   /**
+    * Override the {@link StandardSession#isValid() superclass method}
+    * to call {@ #isValid(boolean) isValid(true)}.
+    */
+   public boolean isValid()
+   {
+      return isValid(true);
+   }
+   
+   /**
+    * Returns whether the current session is still valid, but
+    * only calls {@link #expire(boolean)} for timed-out sessions
+    * if <code>expireIfInvalid</code> is <code>true</code>.
+    * 
+    * @param expireIfInvalid  <code>true</code> if sessions that have
+    *                         been timed out should be expired
+    */
+   public boolean isValid(boolean expireIfInvalid)
+   {
+      if (this.expiring)
+      {
+         return true;
+      }
 
+      if (!this.isValid)
+      {
+         return false;
+      }
+
+      if (accessCount > 0)
+      {
+         return true;
+      }
+
+      if (maxInactiveInterval >= 0)
+      {
+         long timeNow = System.currentTimeMillis();
+         int timeIdle = (int) ((timeNow - thisAccessedTime) / 1000L);
+         if (timeIdle >= maxInactiveInterval)
+         {
+            if (expireIfInvalid)
+               expire(true);
+            else
+               return false;
+         }
+      }
+
+      return (this.isValid);
+      
+   }   
+
   /**
    * Override here to reverse the order of manager session removal and
    * attribute removal.

Modified: branches/JBoss_4_0_3_SP1_JBAS-3814/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java
===================================================================
--- branches/JBoss_4_0_3_SP1_JBAS-3814/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java	2006-11-03 19:55:35 UTC (rev 58087)
+++ branches/JBoss_4_0_3_SP1_JBAS-3814/tomcat/src/main/org/jboss/web/tomcat/tc5/session/JBossCacheManager.java	2006-11-03 20:09:44 UTC (rev 58088)
@@ -680,6 +680,20 @@
                if(doTx)
                   tm.begin();
 
+               // JBAS-2403. Check for outdated sessions where we think
+               // the local copy has timed out.  If found, refresh the
+               // session from the cache in case that might change the timeout
+               if (session.isOutdated() && session.isValid(false) == false) {
+                  String realId = getRealId(session.getId());
+                  // JBAS-2792 don't assign the result of loadSession to session
+                  // just update the object from the cache or fall through if
+                  // the session has been removed from the cache
+                  loadSession(realId);
+               }
+               
+               // Do a normal invalidation check that will expire any
+               // sessions that have timed out
+
                if (!session.isValid()) continue;
             }
             catch (Exception ex)




More information about the jboss-cvs-commits mailing list