From c2b7aad4b62be9c807cd3c08f0c3d6ad72f4f1c6 Mon Sep 17 00:00:00 2001 From: Artur Signell Date: Thu, 29 Nov 2012 18:28:14 +0200 Subject: [PATCH] Made session reinitializing work again (#10411) Change-Id: I012a5154fa3cf0bba6f3289213744b740cf12059 --- server/src/com/vaadin/server/VaadinService.java | 7 +------ server/src/com/vaadin/server/VaadinSession.java | 6 ++++++ .../tests/applicationcontext/ChangeSessionId.html | 15 ++++++++++++--- 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java index 5338ec217b..6794be4dbd 100644 --- a/server/src/com/vaadin/server/VaadinService.java +++ b/server/src/com/vaadin/server/VaadinService.java @@ -47,7 +47,7 @@ import com.vaadin.util.ReflectTools; * @since 7.0 */ public abstract class VaadinService implements Serializable { - private static final String REINITIALIZING_SESSION_MARKER = VaadinService.class + static final String REINITIALIZING_SESSION_MARKER = VaadinService.class .getName() + ".reinitializing"; private static final Method SESSION_INIT_METHOD = ReflectTools.findMethod( @@ -329,11 +329,6 @@ public abstract class VaadinService implements Serializable { } public void fireSessionDestroy(VaadinSession vaadinSession) { - // Ignore if the session is being moved to a different backing session - if (vaadinSession.getAttribute(REINITIALIZING_SESSION_MARKER) == Boolean.TRUE) { - return; - } - for (UI ui : new ArrayList(vaadinSession.getUIs())) { // close() called here for consistency so that it is always called // before a UI is removed. UI.isClosing() is thus always true in diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java index 4aa2ef5d92..18db4127f4 100644 --- a/server/src/com/vaadin/server/VaadinSession.java +++ b/server/src/com/vaadin/server/VaadinSession.java @@ -162,6 +162,12 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable { + "This might happen if a session is deserialized but never used before it expires."); } else if (VaadinService.getCurrentRequest() != null && getCurrent() == this) { + // Ignore if the session is being moved to a different backing + // session + if (getAttribute(VaadinService.REINITIALIZING_SESSION_MARKER) == Boolean.TRUE) { + return; + } + // There is still a request in progress for this session. The // session will be destroyed after the response has been written. if (!isClosing()) { diff --git a/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.html b/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.html index 6d028f1fea..6bf4041a93 100644 --- a/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.html +++ b/uitest/src/com/vaadin/tests/applicationcontext/ChangeSessionId.html @@ -16,11 +16,21 @@ /run/com.vaadin.tests.applicationcontext.ChangeSessionId?restartApplication + + assertText + vaadin=runcomvaadintestsapplicationcontextChangeSessionId::PID_SLog_row_0 + 1. Session id: * + click vaadin=runcomvaadintestsapplicationcontextChangeSessionId::/VVerticalLayout[0]/ChildComponentContainer[1]/VButton[0]/domChild[0]/domChild[0] + + assertText + vaadin=runcomvaadintestsapplicationcontextChangeSessionId::PID_SLog_row_0 + 2. Session id changed successfully from * to * + click vaadin=runcomvaadintestsapplicationcontextChangeSessionId::/VVerticalLayout[0]/ChildComponentContainer[2]/VButton[0]/domChild[0]/domChild[0] @@ -28,10 +38,9 @@ assertText - vaadin=runcomvaadintestsapplicationcontextChangeSessionId::PID_SLog_row_1 - 2. Session id changed successfully from * to * + vaadin=runcomvaadintestsapplicationcontextChangeSessionId::PID_SLog_row_0 + 3. Session id: * - -- 2.39.5