Enhancements to fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=43343...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 13 Jun 2009 19:05:56 +0000 (19:05 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Sat, 13 Jun 2009 19:05:56 +0000 (19:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@784453 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/session/PersistentManagerBase.java
webapps/docs/config/manager.xml

index 67ab712..4aa4526 100644 (file)
@@ -1054,12 +1054,11 @@ public abstract class PersistentManagerBase
                     int timeIdle = // Truncate, do not round up
                         (int) ((timeNow - session.getThisAccessedTime()) / 1000L);
                     if (timeIdle > maxIdleSwap && timeIdle > minIdleSwap) {
-                        if (sessions[i] instanceof StandardSession) {
-                            if (((StandardSession) sessions[i]).accessCount.get() > 0) {
-                                // Session is currently being accessed - skip it
-                                continue;
-                            }
-                        }                       
+                        if (session.accessCount != null &&
+                                session.accessCount.get() > 0) {
+                            // Session is currently being accessed - skip it
+                            continue;
+                        }
                         if (log.isDebugEnabled())
                             log.debug(sm.getString
                                 ("persistentManager.swapMaxIdle",
@@ -1100,22 +1099,22 @@ public abstract class PersistentManagerBase
         long timeNow = System.currentTimeMillis();
 
         for (int i = 0; i < sessions.length && toswap > 0; i++) {
-            synchronized (sessions[i]) {
+            StandardSession session =  (StandardSession) sessions[i];
+            synchronized (session) {
                 int timeIdle = // Truncate, do not round up
-                    (int) ((timeNow - sessions[i].getThisAccessedTime()) / 1000L);
+                    (int) ((timeNow - session.getThisAccessedTime()) / 1000L);
                 if (timeIdle > minIdleSwap) {
-                    if (sessions[i] instanceof StandardSession) {
-                        if (((StandardSession) sessions[i]).accessCount.get() > 0) {
-                            // Session is currently being accessed - skip it
-                            continue;
-                        }
+                    if (session.accessCount != null &&
+                            session.accessCount.get() > 0) {
+                        // Session is currently being accessed - skip it
+                        continue;
                     }
                     if(log.isDebugEnabled())
                         log.debug(sm.getString
                             ("persistentManager.swapTooManyActive",
-                             sessions[i].getIdInternal(), new Integer(timeIdle)));
+                             session.getIdInternal(), new Integer(timeIdle)));
                     try {
-                        swapOut(sessions[i]);
+                        swapOut(session);
                     } catch (IOException e) {
                         // This is logged in writeSession()
                     }
index 5ed3a40..8362b91 100644 (file)
     has not been thoroughly tested, and should be considered experimental!
     </strong></em></p>
 
+    <p><strong>NOTE:</strong> You must set either the
+    <code>org.apache.catalina.session.StandardSession.ACTIVITY_CHECK</code> or
+    <code>org.apache.catalina.STRICT_SERVLET_COMPLIANCE</code>
+    <a href="systemprops.html">system properties</a> to <code>true</code> for
+    the persistent manager to work correctly.</p>
+    
     <p>The persistent implementation of <strong>Manager</strong> is
     <strong>org.apache.catalina.session.PersistentManager</strong>.  In
     addition to the usual operations of creating and deleting sessions, a