summaryrefslogtreecommitdiffstats
path: root/server/src
diff options
context:
space:
mode:
authorTeemu Suo-Anttila <tsuoanttila@users.noreply.github.com>2017-11-27 13:15:56 +0200
committerAleksi Hietanen <aleksi@vaadin.com>2017-11-27 13:15:56 +0200
commitd936003c92a8e3ac2e1c0637ac240f3d7624bc0d (patch)
tree2c0e2f93caf60ed4590d0dee3fd0a4226088fc5e /server/src
parent780cab157d03a8ca81dec3667fe235ec10207efe (diff)
downloadvaadin-framework-d936003c92a8e3ac2e1c0637ac240f3d7624bc0d.tar.gz
vaadin-framework-d936003c92a8e3ac2e1c0637ac240f3d7624bc0d.zip
Prevent killing UI if heartbeats are pending (#10371)
Fixes #9663
Diffstat (limited to 'server/src')
-rw-r--r--server/src/main/java/com/vaadin/server/VaadinService.java23
1 files changed, 18 insertions, 5 deletions
diff --git a/server/src/main/java/com/vaadin/server/VaadinService.java b/server/src/main/java/com/vaadin/server/VaadinService.java
index d086b68a12..9b9c7fd913 100644
--- a/server/src/main/java/com/vaadin/server/VaadinService.java
+++ b/server/src/main/java/com/vaadin/server/VaadinService.java
@@ -1363,12 +1363,25 @@ public abstract class VaadinService implements Serializable {
public boolean isUIActive(UI ui) {
if (ui.isClosing()) {
return false;
- } else {
- long now = System.currentTimeMillis();
- int timeout = 1000 * getHeartbeatTimeout();
- return timeout < 0
- || now - ui.getLastHeartbeatTimestamp() < timeout;
}
+
+ // Check for long running tasks
+ Lock lockInstance = ui.getSession().getLockInstance();
+ if (lockInstance instanceof ReentrantLock) {
+ if (((ReentrantLock) lockInstance).hasQueuedThreads()) {
+ /*
+ * Someone is trying to access the session. Leaving all UIs
+ * alive for now. A possible kill decision will be made at a
+ * later time when the session access has ended.
+ */
+ return true;
+ }
+ }
+
+ // Check timeout
+ long now = System.currentTimeMillis();
+ int timeout = 1000 * getHeartbeatTimeout();
+ return timeout < 0 || now - ui.getLastHeartbeatTimestamp() < timeout;
}
/**