summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-08-13 13:17:41 +0300
committerLeif Åstrand <leif@vaadin.com>2013-08-13 13:17:59 +0300
commitf72be69c60432bb94251cd7a73ad167062f9c6a8 (patch)
treea2439d77303348e18a437fd933eecf3eb64a0e09
parenteaec28197b1b9791a75e69adc5d01e1ffb0929a8 (diff)
downloadvaadin-framework-f72be69c60432bb94251cd7a73ad167062f9c6a8.tar.gz
vaadin-framework-f72be69c60432bb94251cd7a73ad167062f9c6a8.zip
Terminate JVM if server.close() has no effect (#12363)
Change-Id: If024d94d496a6cf2e6f0f342d368ac7bd746de38
-rw-r--r--uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java43
1 files changed, 43 insertions, 0 deletions
diff --git a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java
index 070cd2834d..99f9707479 100644
--- a/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java
+++ b/uitest/src/com/vaadin/launcher/DevelopmentServerLauncher.java
@@ -26,6 +26,7 @@ import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.HashMap;
import java.util.Map;
+import java.util.Map.Entry;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
@@ -212,8 +213,35 @@ public class DevelopmentServerLauncher {
Socket accept = serverSocket.accept();
// First stop listening to the port
serverSocket.close();
+ final Thread stopThread = Thread.currentThread();
+
+ // Start a thread that kills the JVM if
+ // server.stop() doesn't have any effect
+ Thread interruptThread = new Thread() {
+ @Override
+ public void run() {
+ try {
+ Thread.sleep(5000);
+ if (!server.isStopped()) {
+ System.out
+ .println("Jetty still running. Closing JVM.");
+ dumpThreadStacks();
+ System.exit(-1);
+ }
+ } catch (InterruptedException e) {
+ // Interrupted if server.stop() was
+ // successful
+ }
+ }
+ };
+ interruptThread.setDaemon(true);
+ interruptThread.start();
+
// Then stop the jetty server
server.stop();
+
+ interruptThread.interrupt();
+
// Send a byte to tell the other process that it can
// start jetty
OutputStream outputStream = accept
@@ -352,4 +380,19 @@ public class DevelopmentServerLauncher {
}
+ private static void dumpThreadStacks() {
+ for (Entry<Thread, StackTraceElement[]> entry : Thread
+ .getAllStackTraces().entrySet()) {
+ Thread thread = entry.getKey();
+ StackTraceElement[] stackTraceElements = entry.getValue();
+
+ System.out.println(thread.getName() + " - " + thread.getState());
+ for (StackTraceElement stackTraceElement : stackTraceElements) {
+ System.out.println(" at " + stackTraceElement.toString());
+ }
+ System.out.println();
+ }
+
+ }
+
}