resolve issue: java.lang.IllegalStateException: Shutdown in progress

This commit is contained in:
Jarred Li
2012-08-14 15:48:42 +08:00
parent 0f5a0fc85c
commit 7acc0db4de
3 changed files with 16 additions and 4 deletions

View File

@@ -0,0 +1 @@
log4j.rootCategory=OFF

View File

@@ -88,8 +88,6 @@ public class Bootstrap {
for (Converter converter : converters.values()) {
shell.getSimpleParser().add(converter);
}
shell.start();
}
private void createApplicationContext() {
@@ -186,6 +184,7 @@ public class Bootstrap {
}
}
else {
shell.start();
shell.promptLoop();
exitShellRequest = shell.getExitShellRequest();
if (exitShellRequest == null) {

View File

@@ -87,6 +87,7 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker,
private final Map<String, FlashInfo> flashInfoMap = new HashMap<String, FlashInfo>();
/** key: row number, value: eraseLineFromPosition */
private final Map<Integer, Integer> rowErasureMap = new HashMap<Integer, Integer>();
private boolean shutdownHookFired = false; // ROO-1599
private int historySize;
@@ -129,7 +130,15 @@ public abstract class JLineShell extends AbstractShell implements CommandMarker,
setShellStatus(Status.STARTED);
try {
// Monitor CTRL+C initiated shutdowns (ROO-1599)
Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
public void run() {
shutdownHookFired = true;
}
}, getProductName() + " JLine Shutdown Hook"));
} catch (Throwable t) {
}
// Handle any "execute-then-quit" operation
@@ -290,7 +299,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)) {
while (!shellStatus.getStatus().equals(Status.SHUTTING_DOWN) && !shutdownHookFired) {
synchronized (flashInfoMap) {
long now = System.currentTimeMillis();
@@ -426,6 +435,9 @@ 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) {