summaryrefslogtreecommitdiffstats
path: root/uitest
diff options
context:
space:
mode:
authorArtur Signell <artur@vaadin.com>2016-10-06 23:07:20 +0300
committerPekka Hyvönen <pekka@vaadin.com>2016-12-09 09:39:00 +0200
commitd20fc36768c9d2c74b40b34c931da8d842d0a67e (patch)
treed5939af6c068bd9483dd9fbffa86758cbde95b6e /uitest
parent7b39a6dd527e80499261d1e93a48af9ab629f25c (diff)
downloadvaadin-framework-d20fc36768c9d2c74b40b34c931da8d842d0a67e.tar.gz
vaadin-framework-d20fc36768c9d2c74b40b34c931da8d842d0a67e.zip
Workaround for deadlock issue (#18436)
Change-Id: I4e32550e3d3095c2c914bb93d260819414d2e6e6
Diffstat (limited to 'uitest')
-rw-r--r--uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java120
1 files changed, 120 insertions, 0 deletions
diff --git a/uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java b/uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java
new file mode 100644
index 0000000000..4d6e9c4c21
--- /dev/null
+++ b/uitest/src/main/java/com/vaadin/tests/push/PushWebsocketDeadlockUI.java
@@ -0,0 +1,120 @@
+package com.vaadin.tests.push;
+
+import com.vaadin.annotations.Push;
+import com.vaadin.server.SessionDestroyEvent;
+import com.vaadin.server.SessionDestroyListener;
+import com.vaadin.server.VaadinRequest;
+import com.vaadin.server.WrappedSession;
+import com.vaadin.shared.ui.ui.Transport;
+import com.vaadin.tests.components.AbstractTestUIWithLog;
+import com.vaadin.ui.Button;
+import com.vaadin.ui.Button.ClickEvent;
+import com.vaadin.ui.Button.ClickListener;
+import com.vaadin.ui.Label;
+
+@Push(transport = Transport.WEBSOCKET)
+public class PushWebsocketDeadlockUI extends AbstractTestUIWithLog {
+
+ // Test for https://dev.vaadin.com/ticket/18436
+ // Needs breakpoints to test, see ticket for more information
+ // Can reproduce on Tomcat 8, can't seem to reproduce using
+ // DevelopmentServerLauncher
+
+ // Rough steps to reproduce
+ // 1. Open test in a new Chrome window
+ // 2. Set breakpoint in PushHandler.connectionLost
+ // 3. Set breakpoint in UI.close
+ // 4. Set breakpoint in PushRequestHandler.handleRequest
+ // 5. Click the "schedule UI close" button
+ // 6. Close the Chrome window before the 5s timeout expires and ensure it
+ // really closes
+ // 7. Wait for three threads to hit their breakpoints
+ // 8. Continue/step forward in proper order (see ticket)
+
+ @Override
+ protected void setup(VaadinRequest request) {
+ WrappedSession wrappedSession = getSession().getSession();
+ request.getService()
+ .addSessionDestroyListener(new SessionDestroyListener() {
+ @Override
+ public void sessionDestroy(SessionDestroyEvent e) {
+ System.out.println(
+ "Session " + e.getSession() + " destroyed");
+ }
+ });
+ final Label l = new Label("Session timeout is "
+ + wrappedSession.getMaxInactiveInterval() + "s");
+ addComponents(l);
+
+ Button button = new Button("Invalidate session");
+ button.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent e) {
+ System.out.println(
+ "invalidating " + getSession() + " for http session "
+ + getSession().getSession().getId());
+ getSession().getSession().invalidate();
+ System.out.println("invalidated " + getSession());
+ }
+ });
+ addComponents(button);
+ button = new Button("Close UI");
+ button.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent e) {
+ System.out.println("closing UI " + getUIId() + " in session "
+ + getSession() + " for http session "
+ + getSession().getSession().getId());
+ close();
+ }
+ });
+ addComponents(button);
+ button = new Button("Schedule Close UI (5s delay)");
+ button.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent e) {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ // Breakpoint here
+ access(new Runnable() {
+ @Override
+ public void run() {
+ close();
+ System.out.println("closing UI " + getUIId()
+ + " in session " + getSession()
+ + " for http session "
+ + getSession().getSession().getId());
+
+ }
+ });
+
+ }
+ }).start();
+ }
+ });
+ addComponents(button);
+ button = new Button("Slow (5s) operation");
+ button.addClickListener(new ClickListener() {
+ @Override
+ public void buttonClick(ClickEvent e) {
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ addComponent(new Label("Slow operation done"));
+ }
+ });
+
+ addComponents(button);
+
+ }
+
+}