Repository: wicket
Updated Branches:
  refs/heads/wicket-7.x 242d4e9e1 -> ccc7abcf4


WICKET-6530: fix possible race-condition for session invalidation


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/ccc7abcf
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/ccc7abcf
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/ccc7abcf

Branch: refs/heads/wicket-7.x
Commit: ccc7abcf4f7db4405f70631e7779551fde3a87cc
Parents: 242d4e9
Author: Emond Papegaaij <[email protected]>
Authored: Mon Feb 5 14:10:21 2018 +0100
Committer: Emond Papegaaij <[email protected]>
Committed: Mon Feb 5 15:47:23 2018 +0100

----------------------------------------------------------------------
 .../src/main/java/org/apache/wicket/Session.java    | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/ccc7abcf/wicket-core/src/main/java/org/apache/wicket/Session.java
----------------------------------------------------------------------
diff --git a/wicket-core/src/main/java/org/apache/wicket/Session.java 
b/wicket-core/src/main/java/org/apache/wicket/Session.java
index 691355e..4bebe2c 100644
--- a/wicket-core/src/main/java/org/apache/wicket/Session.java
+++ b/wicket-core/src/main/java/org/apache/wicket/Session.java
@@ -113,6 +113,12 @@ public abstract class Session implements IClusterable, 
IEventSink
        /** Logging object */
        private static final Logger log = 
LoggerFactory.getLogger(Session.class);
 
+       /** records if session has been invalidated by the current request */
+       private static final MetaDataKey<Boolean> SESSION_INVALIDATED = new 
MetaDataKey<Boolean>()
+       {
+               private static final long serialVersionUID = 1L;
+       };
+
        /** Name of session attribute under which this session is stored */
        public static final String SESSION_ATTRIBUTE_NAME = "session";
 
@@ -191,9 +197,6 @@ public abstract class Session implements IClusterable, 
IEventSink
        /** Application level meta data. */
        private MetaDataEntry<?>[] metaData;
 
-       /** True, if session has been invalidated */
-       private transient volatile boolean sessionInvalidated = false;
-
        /**
         * Temporary instance of the session store. Should be set on each 
request as it is not supposed
         * to go in the session.
@@ -480,7 +483,7 @@ public abstract class Session implements IClusterable, 
IEventSink
         */
        public void invalidate()
        {
-               sessionInvalidated = true;
+               RequestCycle.get().setMetaData(SESSION_INVALIDATED, true);
        }
 
        /**
@@ -493,6 +496,7 @@ public abstract class Session implements IClusterable, 
IEventSink
                        
sessionStore.invalidate(RequestCycle.get().getRequest());
                        sessionStore = null;
                        id = null;
+                       RequestCycle.get().setMetaData(SESSION_INVALIDATED, 
false);
                }
        }
 
@@ -533,7 +537,7 @@ public abstract class Session implements IClusterable, 
IEventSink
         */
        public final boolean isSessionInvalidated()
        {
-               return sessionInvalidated;
+               return 
Boolean.TRUE.equals(RequestCycle.get().getMetaData(SESSION_INVALIDATED));
        }
 
        /**
@@ -650,7 +654,7 @@ public abstract class Session implements IClusterable, 
IEventSink
        {
                detachFeedback();
 
-               if (sessionInvalidated)
+               if (isSessionInvalidated())
                {
                        invalidateNow();
                }

Reply via email to