resolve issue: java.lang.IllegalStateException: Shutdown in progress
This commit is contained in:
1
samples/helloworld/src/main/resources/log4j.properties
Normal file
1
samples/helloworld/src/main/resources/log4j.properties
Normal file
@@ -0,0 +1 @@
|
||||
log4j.rootCategory=OFF
|
||||
@@ -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) {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user