Extract nested trys
Signed-off-by: Emmanuel Bigeon <emmanuel@bigeon.fr>
This commit is contained in:
parent
0bbe9d321d
commit
b5f1463864
@ -236,16 +236,7 @@ public class SocketConsoleApplicationShell implements Runnable, AutoCloseable {
|
|||||||
}
|
}
|
||||||
runnable.setRunning(false);
|
runnable.setRunning(false);
|
||||||
try {
|
try {
|
||||||
consoleManager.type(applicationShutdown);
|
closeManager(appThNext);
|
||||||
try {
|
|
||||||
appThNext.join(ONE_TENTH_OF_SECOND);
|
|
||||||
} catch (InterruptedException e) {
|
|
||||||
LOGGER.warning("Application thread was interrupted!"); //$NON-NLS-1$
|
|
||||||
LOGGER.log(Level.FINE,
|
|
||||||
"Application thread was interrupted while closing", //$NON-NLS-1$
|
|
||||||
e);
|
|
||||||
}
|
|
||||||
consoleManager.close();
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
LOGGER.warning("Unable to close application correctly"); //$NON-NLS-1$
|
LOGGER.warning("Unable to close application correctly"); //$NON-NLS-1$
|
||||||
LOGGER.log(Level.FINE, "Application closing caused an exception", //$NON-NLS-1$
|
LOGGER.log(Level.FINE, "Application closing caused an exception", //$NON-NLS-1$
|
||||||
@ -254,6 +245,24 @@ public class SocketConsoleApplicationShell implements Runnable, AutoCloseable {
|
|||||||
LOGGER.info("Closing Server"); //$NON-NLS-1$
|
LOGGER.info("Closing Server"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Close the console manager after writing the application shutdown
|
||||||
|
* command.
|
||||||
|
*
|
||||||
|
* @param appThNext the thread containing the application
|
||||||
|
* @throws IOException if the typyng or closing failed */
|
||||||
|
private void closeManager(Thread appThNext) throws IOException {
|
||||||
|
consoleManager.type(applicationShutdown);
|
||||||
|
try {
|
||||||
|
appThNext.join(ONE_TENTH_OF_SECOND);
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
LOGGER.warning("Application thread was interrupted!"); //$NON-NLS-1$
|
||||||
|
LOGGER.log(Level.FINE,
|
||||||
|
"Application thread was interrupted while closing", //$NON-NLS-1$
|
||||||
|
e);
|
||||||
|
}
|
||||||
|
consoleManager.close();
|
||||||
|
}
|
||||||
|
|
||||||
/** @param runnable the runnable */
|
/** @param runnable the runnable */
|
||||||
private void startApplication(ConsoleRunnable runnable) {
|
private void startApplication(ConsoleRunnable runnable) {
|
||||||
runnable.restart();
|
runnable.restart();
|
||||||
|
Loading…
Reference in New Issue
Block a user