blob: 20d4877896ca8d82bb5753449a1adc5b43b8bcb4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
|
package com.vaadin.tests.push;
import com.vaadin.annotations.Push;
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.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(event -> System.out
.println("Session " + event.getSession() + " destroyed"));
final Label l = new Label("Session timeout is "
+ wrappedSession.getMaxInactiveInterval() + "s");
addComponents(l);
Button button = new Button("Invalidate session");
button.addClickListener(event -> {
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(event -> {
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(event -> {
new Thread(() -> {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Breakpoint here
access(() -> {
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(event -> {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
addComponent(new Label("Slow operation done"));
});
addComponents(button);
}
}
|