From: markt Date: Sat, 13 Jun 2009 19:05:56 +0000 (+0000) Subject: Enhancements to fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=43343... X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=6121bd3f090468979fed09553e55abe19a86e43f;p=tomcat7.0 Enhancements to fix for https://issues.apache.org/bugzilla/show_bug.cgi?id=43343 based on kkolinko's review git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@784453 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/java/org/apache/catalina/session/PersistentManagerBase.java b/java/org/apache/catalina/session/PersistentManagerBase.java index 67ab71210..4aa4526e7 100644 --- a/java/org/apache/catalina/session/PersistentManagerBase.java +++ b/java/org/apache/catalina/session/PersistentManagerBase.java @@ -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() } diff --git a/webapps/docs/config/manager.xml b/webapps/docs/config/manager.xml index 5ed3a4064..8362b914f 100644 --- a/webapps/docs/config/manager.xml +++ b/webapps/docs/config/manager.xml @@ -165,6 +165,12 @@ has not been thoroughly tested, and should be considered experimental!

+

NOTE: You must set either the + org.apache.catalina.session.StandardSession.ACTIVITY_CHECK or + org.apache.catalina.STRICT_SERVLET_COMPLIANCE + system properties to true for + the persistent manager to work correctly.

+

The persistent implementation of Manager is org.apache.catalina.session.PersistentManager. In addition to the usual operations of creating and deleting sessions, a