Fix for AVATAR_JS-85, keep rootcause and rethrow it

Reviewed-by: asquare
This commit is contained in:
jfdenise 2013-11-19 19:08:13 +01:00
parent f1e5a2fab2
commit b60c8cb0cc

View File

@ -209,6 +209,7 @@ public final class Server {
holder.setArgs(avatarArgs.toArray(new String[avatarArgs.size()]),
userArgs.toArray(new String[userArgs.size()]),
userFiles);
Exception rootCause = null;
try {
runSystemScript(SYSTEM_INIT_SCRIPTS);
// run the main event loop
@ -218,11 +219,20 @@ public final class Server {
eventLoop.stop();
}
holder.setExitCode(1);
rootCause = ex;
throw ex;
} finally {
if (args != null && args.length > 0) {
// emit the process.exit event
runSystemScript(SYSTEM_FINALIZATION_SCRIPTS);
try {
// emit the process.exit event
runSystemScript(SYSTEM_FINALIZATION_SCRIPTS);
} catch (Exception ex) {
if (rootCause != null) {
rootCause.addSuppressed(ex);
throw rootCause;
}
throw ex;
}
}
}
}