summaryrefslogtreecommitdiffstats
path: root/server
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-07-12 10:05:53 +0300
committerVaadin Code Review <review@vaadin.com>2013-07-17 06:30:51 +0000
commit654d5707a98fb0e2309cc5aa5c8b6bbcf7d10491 (patch)
tree2099d3a0c95ae39fd238880dc8e4e645157b720b /server
parent3229847265dc30cced90e6718bd477cf4e9fbdf4 (diff)
downloadvaadin-framework-654d5707a98fb0e2309cc5aa5c8b6bbcf7d10491.tar.gz
vaadin-framework-654d5707a98fb0e2309cc5aa5c8b6bbcf7d10491.zip
Don't close an unbound VaadinSession for GAEVaadinServlet (#12209)
Change-Id: If3480eb6e21f5f19a43b8dc0d6279173ff3bec40
Diffstat (limited to 'server')
-rw-r--r--server/src/com/vaadin/server/GAEVaadinServlet.java11
-rw-r--r--server/src/com/vaadin/server/VaadinService.java24
-rw-r--r--server/src/com/vaadin/server/VaadinSession.java8
3 files changed, 36 insertions, 7 deletions
diff --git a/server/src/com/vaadin/server/GAEVaadinServlet.java b/server/src/com/vaadin/server/GAEVaadinServlet.java
index 5a12295d9d..6690da7562 100644
--- a/server/src/com/vaadin/server/GAEVaadinServlet.java
+++ b/server/src/com/vaadin/server/GAEVaadinServlet.java
@@ -401,7 +401,18 @@ public class GAEVaadinServlet extends VaadinServlet {
if (serviceSession == null) {
return;
}
+
+ /*
+ * Inform VaadinSession.valueUnbound that it should not kill the session
+ * even though it gets unbound.
+ */
+ serviceSession.setAttribute(
+ VaadinService.PRESERVE_UNBOUND_SESSION_ATTRIBUTE, Boolean.TRUE);
serviceSession.removeFromSession(getService());
+
+ // Remove preservation marker
+ serviceSession.setAttribute(
+ VaadinService.PRESERVE_UNBOUND_SESSION_ATTRIBUTE, null);
}
/**
diff --git a/server/src/com/vaadin/server/VaadinService.java b/server/src/com/vaadin/server/VaadinService.java
index cfbf2606ae..1be5bd5c99 100644
--- a/server/src/com/vaadin/server/VaadinService.java
+++ b/server/src/com/vaadin/server/VaadinService.java
@@ -71,9 +71,25 @@ import com.vaadin.util.ReflectTools;
* @since 7.0
*/
public abstract class VaadinService implements Serializable {
- static final String REINITIALIZING_SESSION_MARKER = VaadinService.class
+ /**
+ * Attribute name for telling
+ * {@link VaadinSession#valueUnbound(javax.servlet.http.HttpSessionBindingEvent)}
+ * that it should not close a {@link VaadinSession} even though it gets
+ * unbound. If a {@code VaadinSession} has an attribute with this name and
+ * the attribute value is {@link Boolean#TRUE}, that session will not be
+ * closed when it is unbound from the underlying session.
+ */
+ // Use the old name.reinitializing value for backwards compatibility
+ static final String PRESERVE_UNBOUND_SESSION_ATTRIBUTE = VaadinService.class
.getName() + ".reinitializing";
+ /**
+ * @deprecated As of 7.1.1, use {@link #PRESERVE_UNBOUND_SESSION_ATTRIBUTE}
+ * instead
+ */
+ @Deprecated
+ static final String REINITIALIZING_SESSION_MARKER = PRESERVE_UNBOUND_SESSION_ATTRIBUTE;
+
private static final Method SESSION_INIT_METHOD = ReflectTools.findMethod(
SessionInitListener.class, "sessionInit", SessionInitEvent.class);
@@ -970,7 +986,7 @@ public abstract class VaadinService implements Serializable {
if (value instanceof VaadinSession) {
// set flag to avoid cleanup
VaadinSession serviceSession = (VaadinSession) value;
- serviceSession.setAttribute(REINITIALIZING_SESSION_MARKER,
+ serviceSession.setAttribute(PRESERVE_UNBOUND_SESSION_ATTRIBUTE,
Boolean.TRUE);
}
attrs.put(name, value);
@@ -997,8 +1013,8 @@ public abstract class VaadinService implements Serializable {
serviceSession.getLockInstance());
serviceSession.storeInSession(service, newSession);
- serviceSession
- .setAttribute(REINITIALIZING_SESSION_MARKER, null);
+ serviceSession.setAttribute(PRESERVE_UNBOUND_SESSION_ATTRIBUTE,
+ null);
}
}
diff --git a/server/src/com/vaadin/server/VaadinSession.java b/server/src/com/vaadin/server/VaadinSession.java
index 890b2eba29..8f27241384 100644
--- a/server/src/com/vaadin/server/VaadinSession.java
+++ b/server/src/com/vaadin/server/VaadinSession.java
@@ -240,9 +240,11 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
} else if (VaadinService.getCurrentRequest() != null
&& getCurrent() == this) {
assert hasLock();
- // Ignore if the session is being moved to a different backing
- // session
- if (getAttribute(VaadinService.REINITIALIZING_SESSION_MARKER) == Boolean.TRUE) {
+ /*
+ * Ignore if the session is being moved to a different backing
+ * session or if GAEVaadinServlet is doing its normal cleanup.
+ */
+ if (getAttribute(VaadinService.PRESERVE_UNBOUND_SESSION_ATTRIBUTE) == Boolean.TRUE) {
return;
}