changeset 10472:229b10e97bd2

2228674: Fix failed for CR 7162144 Reviewed-by: art, anthony
author bagiras
date Wed, 16 Oct 2013 19:02:10 +0400
parents 89546b9be510
children 70242d821c66
files src/share/classes/java/awt/EventDispatchThread.java src/share/classes/java/awt/EventQueue.java
diffstat 2 files changed, 15 insertions(+), 42 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/awt/EventDispatchThread.java	Tue Oct 15 20:40:21 2013 +0400
+++ b/src/share/classes/java/awt/EventDispatchThread.java	Wed Oct 16 19:02:10 2013 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,19 +25,11 @@
 
 package java.awt;
 
-import java.awt.event.InputEvent;
 import java.awt.event.MouseEvent;
 import java.awt.event.ActionEvent;
 import java.awt.event.WindowEvent;
-import java.lang.reflect.Method;
-import java.security.AccessController;
-import sun.security.action.GetPropertyAction;
-import sun.awt.AWTAutoShutdown;
-import sun.awt.SunToolkit;
-import sun.awt.AppContext;
 
 import java.util.ArrayList;
-import java.util.List;
 import sun.util.logging.PlatformLogger;
 
 import sun.awt.dnd.SunDragSourceContextPeer;
@@ -67,8 +59,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,24 +77,15 @@
         doDispatch = false;
     }
 
-    public void interrupt() {
-        shutdown = true;
-        super.interrupt();
-    }
-
     public void run() {
-        while (true) {
-            try {
-                pumpEvents(new Conditional() {
-                    public boolean evaluate() {
-                        return true;
-                    }
-                });
-            } finally {
-                if(getEventQueue().detachDispatchThread(this, shutdown)) {
-                    break;
+        try {
+            pumpEvents(new Conditional() {
+                public boolean evaluate() {
+                    return true;
                 }
-            }
+            });
+        } finally {
+            getEventQueue().detachDispatchThread(this);
         }
     }
 
@@ -130,8 +112,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);
@@ -223,12 +204,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);
--- a/src/share/classes/java/awt/EventQueue.java	Tue Oct 15 20:40:21 2013 +0400
+++ b/src/share/classes/java/awt/EventQueue.java	Wed Oct 16 19:02:10 2013 +0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1074,7 +1074,7 @@
         }
     }
 
-    final boolean detachDispatchThread(EventDispatchThread edt, boolean forceDetach) {
+    final void detachDispatchThread(EventDispatchThread edt) {
         /*
          * Minimize discard possibility for non-posted events
          */
@@ -1090,17 +1090,9 @@
         pushPopLock.lock();
         try {
             if (edt == dispatchThread) {
-                /*
-                 * Don't detach the thread if any events are pending. Not
-                 * sure if it's a possible scenario, though.
-                 */
-                if (!forceDetach && (peekEvent() != null)) {
-                    return false;
-                }
                 dispatchThread = null;
             }
             AWTAutoShutdown.getInstance().notifyThreadFree(edt);
-            return true;
         } finally {
             pushPopLock.unlock();
         }