6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms
authorart
Fri, 17 Apr 2009 12:46:24 +0400
changeset 2650 44d88464a573
parent 2497 903fd9d785ef
child 2651 c6612086e8c9
6829923: Test javax/swing/system/6799345/TestShutdown.java fails on X11 platforms Summary: XAWT toolkit thread is correctly interrupted when AppContext is disposed Reviewed-by: anthony, peterz
jdk/src/solaris/classes/sun/awt/X11/XToolkit.java
--- a/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Fri Apr 10 11:51:36 2009 +0900
+++ b/jdk/src/solaris/classes/sun/awt/X11/XToolkit.java	Fri Apr 17 12:46:24 2009 +0400
@@ -565,6 +565,17 @@
     {
         XEvent ev = new XEvent();
         while(true) {
+            // Fix for 6829923: we should gracefully handle toolkit thread interruption
+            if (Thread.currentThread().isInterrupted()) {
+                // We expect interruption from the AppContext.dispose() method only.
+                // If the thread is interrupted from another place, let's skip it
+                // for compatibility reasons. Probably some time later we'll remove
+                // the check for AppContext.isDisposed() and will unconditionally
+                // break the loop here.
+                if (AppContext.getAppContext().isDisposed()) {
+                    break;
+                }
+            }
             awtLock();
             try {
                 if (loop == SECONDARY_LOOP) {