changeset 5569:6bd9cb9e37a4

7189350: Fix failed for CR 7162144 Summary: Handle EDT interruption differently Reviewed-by: art, bagiras, serb
author anthony
date Wed, 22 Aug 2012 15:07:26 +0400
parents 0d383753b6a0
children ef52ce0ad900
files src/share/classes/java/awt/EventDispatchThread.java
diffstat 1 files changed, 11 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/awt/EventDispatchThread.java	Tue Oct 02 12:14:45 2012 +0100
+++ b/src/share/classes/java/awt/EventDispatchThread.java	Wed Aug 22 15:07:26 2012 +0400
@@ -67,8 +67,7 @@
     private static final PlatformLogger eventLog = PlatformLogger.getLogger("java.awt.event.EventDispatchThread");
 
     private EventQueue theQueue;
-    private boolean doDispatch = true;
-    private volatile boolean shutdown = false;
+    private volatile boolean doDispatch = true;
 
     private static final int ANY_EVENT = -1;
 
@@ -86,11 +85,6 @@
         doDispatch = false;
     }
 
-    public void interrupt() {
-        shutdown = true;
-        super.interrupt();
-    }
-
     public void run() {
         while (true) {
             try {
@@ -100,7 +94,12 @@
                     }
                 });
             } finally {
-                if(getEventQueue().detachDispatchThread(this, shutdown)) {
+                // 7189350: doDispatch is reset from stopDispatching(),
+                //    on InterruptedException, or ThreadDeath. Either way,
+                //    this indicates that we must force shutting down.
+                if (getEventQueue().detachDispatchThread(this,
+                            !doDispatch || isInterrupted()))
+                {
                     break;
                 }
             }
@@ -158,8 +157,7 @@
     void pumpEventsForFilter(int id, Conditional cond, EventFilter filter) {
         addEventFilter(filter);
         doDispatch = true;
-        shutdown |= isInterrupted();
-        while (doDispatch && !shutdown && cond.evaluate()) {
+        while (doDispatch && !isInterrupted() && cond.evaluate()) {
             pumpOneEventForFilters(id);
         }
         removeEventFilter(filter);
@@ -247,12 +245,12 @@
             }
         }
         catch (ThreadDeath death) {
-            shutdown = true;
+            doDispatch = false;
             throw death;
         }
         catch (InterruptedException interruptedException) {
-            shutdown = true; // AppContext.dispose() interrupts all
-                             // Threads in the AppContext
+            doDispatch = false; // AppContext.dispose() interrupts all
+                                // Threads in the AppContext
         }
         catch (Throwable e) {
             processException(e);