summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2017-07-26 21:53:07 +0300
committerHenri Sara <henri.sara@gmail.com>2017-09-27 10:26:47 +0300
commit48e202a80653c2c8a9e31db11814d23b87d6ec19 (patch)
treed5b2f1764df6ae05066e1294d39100352a46bc9d
parent697f770287bb786b6b5d4944a9202d145e4251f5 (diff)
downloadvaadin-framework-48e202a80653c2c8a9e31db11814d23b87d6ec19.tar.gz
vaadin-framework-48e202a80653c2c8a9e31db11814d23b87d6ec19.zip
Store Vaadin session after each update
This helps clustering solutions know when the session attribute needs to be replicated instead of having to always aggressively replicate all attributes. Resolves #7535
-rw-r--r--server/src/main/java/com/vaadin/server/VaadinSession.java4
-rw-r--r--server/src/test/java/com/vaadin/ui/UITest.java17
2 files changed, 21 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/server/VaadinSession.java b/server/src/main/java/com/vaadin/server/VaadinSession.java
index a49c286f4a..d3da73d993 100644
--- a/server/src/main/java/com/vaadin/server/VaadinSession.java
+++ b/server/src/main/java/com/vaadin/server/VaadinSession.java
@@ -1035,6 +1035,10 @@ public class VaadinSession implements HttpSessionBindingListener, Serializable {
+ ui.getUIId(),
e);
}
+ // Store session after modifications have been done so that
+ // Spring Session and possibly other implementations realize
+ // that something has changed inside the session attribute
+ service.storeSession(this, session);
}
}
} finally {
diff --git a/server/src/test/java/com/vaadin/ui/UITest.java b/server/src/test/java/com/vaadin/ui/UITest.java
index 8bc3c98470..f2fcdcb055 100644
--- a/server/src/test/java/com/vaadin/ui/UITest.java
+++ b/server/src/test/java/com/vaadin/ui/UITest.java
@@ -8,7 +8,9 @@ import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import javax.servlet.ServletConfig;
+import javax.servlet.http.HttpSession;
+import org.easymock.EasyMock;
import org.junit.Assert;
import org.junit.Test;
import org.mockito.Mockito;
@@ -20,6 +22,7 @@ import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.server.VaadinServletService;
import com.vaadin.server.VaadinSession;
+import com.vaadin.server.WrappedHttpSession;
import com.vaadin.server.communication.PushConnection;
import com.vaadin.shared.communication.PushMode;
import com.vaadin.util.CurrentInstanceTest;
@@ -175,7 +178,21 @@ public class UITest {
VaadinServletService service = new VaadinServletService(servlet,
deploymentConfiguration);
MockVaadinSession session = new MockVaadinSession(service);
+ HttpSession mockHttpSession = EasyMock.createMock(HttpSession.class);
+ WrappedHttpSession mockWrappedSession = new WrappedHttpSession(
+ mockHttpSession) {
+ @Override
+ public Object getAttribute(String name) {
+ String lockAttribute = service.getServiceName() + ".lock";
+ if (lockAttribute.equals(name)) {
+ return session.getLockInstance();
+ } else {
+ return super.getAttribute(name);
+ }
+ }
+ };
session.lock();
+ session.refreshTransients(mockWrappedSession, service);
ui.setSession(session);
ui.doInit(Mockito.mock(VaadinRequest.class), 1, "foo");
session.addUI(ui);