@@ -92,28 +92,35 @@ public void start(Stage stage) throws Exception {
9292 public final void onUnexpectedThrowableEvent (UnexpectedThrowableEvent event ) {
9393 // Print throwable before showing the exception so that errors are in order in the console
9494 event .getThrowable ().printStackTrace ();
95- // This should still use PlatformImpl
96- PlatformImpl .runAndWait (() -> {
97- // WARNING! Do not post any events from within this! It could result in a deadlock!
98- synchronized (this .dialogLock ) {
99- try {
100- // Don't create more than one exception dialog at the same time
101- final ExceptionAlert exceptionAlert = new ExceptionAlert (root , event .getThrowable (), event .getMessage (), event .isFatal (), getHostServices ());
102- exceptionAlert .setInitialFocus ();
103- exceptionAlert .showAndWait ();
104- } catch (Throwable e ) {
105- // Well in this case something has gone very, very wrong
106- // We don't want to create a feedback loop either.
107- e .printStackTrace ();
108- System .exit (1 ); // Ensure we shut down the application if we get an exception
109- }
110- }
111- });
11295
113- if (event .isFatal ()) {
114- System .err .println ("Original fatal exception" );
115- event .getThrowable ().printStackTrace ();
116- System .exit (1 );
96+ try {
97+ // If this is an interrupted exception then don't show an error.
98+ // We should exit as fast as possible.
99+ if (!(event .getThrowable () instanceof InterruptedException )) {
100+ // This should still use PlatformImpl
101+ PlatformImpl .runAndWait (() -> {
102+ // WARNING! Do not post any events from within this! It could result in a deadlock!
103+ synchronized (this .dialogLock ) {
104+ try {
105+ // Don't create more than one exception dialog at the same time
106+ final ExceptionAlert exceptionAlert = new ExceptionAlert (root , event .getThrowable (), event .getMessage (), event .isFatal (), getHostServices ());
107+ exceptionAlert .setInitialFocus ();
108+ exceptionAlert .showAndWait ();
109+ } catch (Throwable e ) {
110+ // Well in this case something has gone very, very wrong
111+ // We don't want to create a feedback loop either.
112+ e .printStackTrace ();
113+ System .exit (1 ); // Ensure we shut down the application if we get an exception
114+ }
115+ }
116+ });
117+ }
118+ } finally {
119+ if (event .isFatal ()) {
120+ System .err .println ("Original fatal exception" );
121+ event .getThrowable ().printStackTrace ();
122+ System .exit (1 );
123+ }
117124 }
118125 }
119126}
0 commit comments