changeset 3603:6fd2d28e66cd

6340263: Regression testcase java/awt/dnd/DnDClipboardDeadlockTest throughs IOException: Owner timed out Reviewed-by: anthony, art
author denis
date Fri, 28 Jan 2011 16:52:10 +0300
parents 5f3615691623
children 9da15efec22b
files src/solaris/classes/sun/awt/X11/XSelection.java
diffstat 1 files changed, 19 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/solaris/classes/sun/awt/X11/XSelection.java	Tue Jan 25 19:07:27 2011 +0300
+++ b/src/solaris/classes/sun/awt/X11/XSelection.java	Fri Jan 28 16:52:10 2011 +0300
@@ -301,13 +301,8 @@
                 } finally {
                     XToolkit.awtUnlock();
                 }
-                if (!dataGetter.isExecuted()) {
-                    throw new IOException("Owner timed out");
-                }
 
-                if (dataGetter.isDisposed()) {
-                    throw new IOException("Owner failed to convert data");
-                }
+                validateDataGetter(dataGetter);
 
                 // Handle incremental transfer.
                 if (dataGetter.getActualType() ==
@@ -380,14 +375,7 @@
                                 XToolkit.awtUnlock();
                             }
 
-                            // The owner didn't respond - terminate the transfer.
-                            if (!incrDataGetter.isExecuted()) {
-                                throw new IOException("Owner timed out");
-                            }
-
-                            if (incrDataGetter.isDisposed()) {
-                                throw new IOException("Owner failed to convert data");
-                            }
+                            validateDataGetter(dataGetter);
 
                             if (incrDataGetter.getActualFormat() != 8) {
                                 throw new IOException("Unsupported data format: " +
@@ -445,6 +433,23 @@
         return data != null ? data : new byte[0];
     }
 
+    void validateDataGetter(WindowPropertyGetter propertyGetter)
+            throws IOException
+    {
+        // The order of checks is important because a property getter
+        // has not been executed in case of timeout as well as in case of
+        // changed selection owner.
+
+        if (propertyGetter.isDisposed()) {
+            throw new IOException("Owner failed to convert data");
+        }
+
+        // The owner didn't respond - terminate the transfer.
+        if (!propertyGetter.isExecuted()) {
+            throw new IOException("Owner timed out");
+        }
+    }
+
     // To be MT-safe this method should be called under awtLock.
     boolean isOwner() {
         return isOwner;