Repository: wicket Updated Branches: refs/heads/master 1cec46206 -> 11df645ad
WICKET-6387 ModalWindow PageReference broken Do not remove the session data when the SessionEntry is updated in the Session (cherry picked from commit 95fcc140dc64b8226f54664b70249ec3067e0768) Project: http://git-wip-us.apache.org/repos/asf/wicket/repo Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/9e50533f Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/9e50533f Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/9e50533f Branch: refs/heads/master Commit: 9e50533f2d9546d46686a88146936b25e1f355dd Parents: 1cec462 Author: Martin Tzvetanov Grigorov <[email protected]> Authored: Sun Jun 4 22:48:20 2017 +0200 Committer: Martin Tzvetanov Grigorov <[email protected]> Committed: Sun Jun 4 22:49:51 2017 +0200 ---------------------------------------------------------------------- .../org/apache/wicket/page/PageStoreManager.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/wicket/blob/9e50533f/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java ---------------------------------------------------------------------- diff --git a/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java b/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java index 9a175f9..df956cc 100644 --- a/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java +++ b/wicket-core/src/main/java/org/apache/wicket/page/PageStoreManager.java @@ -24,6 +24,7 @@ import java.util.ArrayList; import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicBoolean; import javax.servlet.http.HttpSessionBindingEvent; import javax.servlet.http.HttpSessionBindingListener; @@ -94,6 +95,16 @@ public class PageStoreManager extends AbstractPageManager private transient List<Object> afterReadObject; /** + * A flag indicating whether this session entry has been re-set in the Session. + * Web containers intercept {@link javax.servlet.http.HttpSession#setAttribute(String, Object)} + * to detect changes and replicate the session. If the attribute has been already + * bound in the session then it will be first unbound and then re-bound again. + * This flag helps us to detect <em>update</em> operations and skip the default behavior + * of {@link #valueUnbound(HttpSessionBindingEvent)}. + */ + private final AtomicBoolean updating = new AtomicBoolean(false); + + /** * Construct. * * @param applicationName @@ -324,6 +335,12 @@ public class PageStoreManager extends AbstractPageManager @Override public void valueUnbound(HttpSessionBindingEvent event) { + if (updating.compareAndSet(true, false)) + { + // The entry has been updated. Do not remove the data + return; + } + // WICKET-5164 use the original sessionId IPageStore store = getPageStore(); // store might be null if destroyed already @@ -432,6 +449,7 @@ public class PageStoreManager extends AbstractPageManager // WICKET-5103 use the same sessionId as used in SessionEntry#getPage() pageStore.storePage(entry.sessionId, page); } + entry.updating.set(true); setSessionAttribute(getAttributeName(), entry); } }
