aboutsummaryrefslogtreecommitdiffstats
path: root/server/src/main/java/com/vaadin
diff options
context:
space:
mode:
authorTatu Lund <tatu@vaadin.com>2021-09-16 12:23:56 +0300
committerGitHub <noreply@github.com>2021-09-16 12:23:56 +0300
commitba5e586b24ba8ddd4b847abcc40a8132b93093cd (patch)
treed916ce3acc8fb0acd14f7d06a8150aaa196e0f95 /server/src/main/java/com/vaadin
parent9141c7a6de641a965dd4e5620fd44452a1691521 (diff)
downloadvaadin-framework-ba5e586b24ba8ddd4b847abcc40a8132b93093cd.tar.gz
vaadin-framework-ba5e586b24ba8ddd4b847abcc40a8132b93093cd.zip
fix: set Vaadin session attribute using lock in reinitializeSession (#12401)
* Cherry picked unit test from Flow See https://github.com/vaadin/flow/pull/11538 * Fix missing import * Cherry pick fix from Flow
Diffstat (limited to 'server/src/main/java/com/vaadin')
-rw-r--r--server/src/main/java/com/vaadin/server/VaadinService.java18
1 files changed, 14 insertions, 4 deletions
diff --git a/server/src/main/java/com/vaadin/server/VaadinService.java b/server/src/main/java/com/vaadin/server/VaadinService.java
index 888b82a3cb..25354074e1 100644
--- a/server/src/main/java/com/vaadin/server/VaadinService.java
+++ b/server/src/main/java/com/vaadin/server/VaadinService.java
@@ -1156,8 +1156,13 @@ public abstract class VaadinService implements Serializable {
if (value instanceof VaadinSession) {
// set flag to avoid cleanup
VaadinSession serviceSession = (VaadinSession) value;
- serviceSession.setAttribute(PRESERVE_UNBOUND_SESSION_ATTRIBUTE,
- Boolean.TRUE);
+ serviceSession.lock();
+ try {
+ serviceSession.setAttribute(
+ PRESERVE_UNBOUND_SESSION_ATTRIBUTE, Boolean.TRUE);
+ } finally {
+ serviceSession.unlock();
+ }
}
attrs.put(name, value);
}
@@ -1183,8 +1188,13 @@ public abstract class VaadinService implements Serializable {
serviceSession.getLockInstance());
service.storeSession(serviceSession, newSession);
- serviceSession.setAttribute(PRESERVE_UNBOUND_SESSION_ATTRIBUTE,
- null);
+ serviceSession.lock();
+ try {
+ serviceSession.setAttribute(
+ PRESERVE_UNBOUND_SESSION_ATTRIBUTE, null);
+ } finally {
+ serviceSession.unlock();
+ }
}
}