From 0f5a0fc85ca6383d6fe990d0ebf8db112038d02c Mon Sep 17 00:00:00 2001 From: Jarred Li Date: Tue, 14 Aug 2012 13:53:27 +0800 Subject: [PATCH] remove JVM shutdown hook --- gradlew | 0 samples/helloworld/pom.xml | 2 -- .../org/springframework/shell/core/JLineShell.java | 14 ++------------ 3 files changed, 2 insertions(+), 14 deletions(-) mode change 100644 => 100755 gradlew diff --git a/gradlew b/gradlew old mode 100644 new mode 100755 diff --git a/samples/helloworld/pom.xml b/samples/helloworld/pom.xml index c0ec5855..49fd6bd8 100644 --- a/samples/helloworld/pom.xml +++ b/samples/helloworld/pom.xml @@ -77,7 +77,6 @@ - spring-roo-repository Spring Roo Maven Repository @@ -92,6 +91,5 @@ Springframework Maven SNAPSHOT Repository http://repo.springsource.org/libs-snapshot - diff --git a/src/main/java/org/springframework/shell/core/JLineShell.java b/src/main/java/org/springframework/shell/core/JLineShell.java index 2f7d2899..28e7e4bf 100644 --- a/src/main/java/org/springframework/shell/core/JLineShell.java +++ b/src/main/java/org/springframework/shell/core/JLineShell.java @@ -87,7 +87,6 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker, private final Map flashInfoMap = new HashMap(); /** key: row number, value: eraseLineFromPosition */ private final Map rowErasureMap = new HashMap(); - private boolean shutdownHookFired = false; // ROO-1599 private int historySize; @@ -130,13 +129,7 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker, setShellStatus(Status.STARTED); - // Monitor CTRL+C initiated shutdowns (ROO-1599) - Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() { - public void run() { - shutdownHookFired = true; - // We don't need to closeShell(), as the shutdown hook in o.s.r.bootstrap.Main calls stop() which calls JLineShellComponent.deactivate() and that calls closeShell() - } - }, getProductName() + " JLine Shutdown Hook")); + // Handle any "execute-then-quit" operation @@ -297,7 +290,7 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker, // Setup a thread to ensure flash messages are displayed and cleared correctly Thread t = new Thread(new Runnable() { public void run() { - while (!shellStatus.getStatus().equals(Status.SHUTTING_DOWN) && !shutdownHookFired) { + while (!shellStatus.getStatus().equals(Status.SHUTTING_DOWN)) { synchronized (flashInfoMap) { long now = System.currentTimeMillis(); @@ -433,9 +426,6 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker, rowErasureMap.remove(row); } else { - if (shutdownHookFired) { - return; // ROO-1599 - } // They want some message displayed int startFrom = reader.getTermwidth() - message.length() + 1; if (startFrom < 1) {