Give thisAccessedTime and lastAccessedTime for sessions
authorrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 Nov 2008 21:56:52 +0000 (21:56 +0000)
committerrjung <rjung@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 5 Nov 2008 21:56:52 +0000 (21:56 +0000)
a clear semantics:

- thisAccessedTime will be updated at the beginning and
  at the end of session use
- lastAccessedTime will only be updated at the end of
  session use

This means:

- lastAccessedTime is the last access time of a session
  disregarding any request still being processed on.
  So this is good to use even from within a request
  to detect when its own session has been used last before.
- thisAccessedTime already gets updated when a new request
  disregarding any request still being processed on.
  So this is better for any idleness check or information.
- thisAccessedTime >= lastAccessedTime always

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@711711 13f79535-47bb-0310-9956-ffa450edef68

java/org/apache/catalina/session/StandardSession.java

index 8659dc3..1d72210 100644 (file)
@@ -617,9 +617,8 @@ public class StandardSession
      */
     public void access() {
 
-        this.lastAccessedTime = this.thisAccessedTime;
         this.thisAccessedTime = System.currentTimeMillis();
-        
+
         if (ACTIVITY_CHECK) {
             accessCount.incrementAndGet();
         }
@@ -633,6 +632,8 @@ public class StandardSession
     public void endAccess() {
 
         isNew = false;
+        this.thisAccessedTime = System.currentTimeMillis();
+        this.lastAccessedTime = this.thisAccessedTime;
 
         if (ACTIVITY_CHECK) {
             accessCount.decrementAndGet();