harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hinde...@apache.org
Subject svn commit: r495701 - in /harmony/enhanced/classlib/trunk/modules/awt/src: main/java/common/java/awt/datatransfer/Clipboard.java test/api/java/common/java/awt/datatransfer/ClipboardTest.java
Date Fri, 12 Jan 2007 19:35:45 GMT
Author: hindessm
Date: Fri Jan 12 11:35:44 2007
New Revision: 495701

URL: http://svn.apache.org/viewvc?view=rev&rev=495701
Log:
Applied patch from "[#HARMONY-2067] [classlib][awt]
Clipboard.setContents(null, null) throws unexpected NPE".

Modified:
    harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Clipboard.java
    harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/datatransfer/ClipboardTest.java

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Clipboard.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Clipboard.java?view=diff&rev=495701&r1=495700&r2=495701
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Clipboard.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/main/java/common/java/awt/datatransfer/Clipboard.java
Fri Jan 12 11:35:44 2007
@@ -66,12 +66,17 @@
             boolean ownershipLost = (this.owner != owner);
             boolean flavorsChanged;
             HashSet<DataFlavor> newFlavorsSet = new HashSet<DataFlavor>();
-            DataFlavor[] newFlavorsArray = contents.getTransferDataFlavors();
+            
+            if (contents != null) {
+                DataFlavor[] newFlavorsArray = contents.getTransferDataFlavors();
 
-            for (DataFlavor element : newFlavorsArray) {
-                newFlavorsSet.add(element);
+                for (DataFlavor element : newFlavorsArray) {
+                    newFlavorsSet.add(element);
+                }
+                flavorsChanged = !flavors.equals(newFlavorsSet);
+            } else {
+                flavorsChanged = (flavors == null) ? false : true;
             }
-            flavorsChanged = !flavors.equals(newFlavorsSet);
 
             if (flavorsChanged || ownershipLost) {
                 processor.setProcessingParams(ownershipLost ? this.owner : null,

Modified: harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/datatransfer/ClipboardTest.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/datatransfer/ClipboardTest.java?view=diff&rev=495701&r1=495700&r2=495701
==============================================================================
--- harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/datatransfer/ClipboardTest.java
(original)
+++ harmony/enhanced/classlib/trunk/modules/awt/src/test/api/java/common/java/awt/datatransfer/ClipboardTest.java
Fri Jan 12 11:35:44 2007
@@ -174,5 +174,11 @@
         assertTrue(string);
         assertTrue(unsupported);
     }
+    
+    public final void testNullContent() throws NullPointerException {
+        // Regression for HARMONY-2067
+        Clipboard c = new Clipboard(""); 
+        c.setContents(null, null); 
+    }
 
 }



Mime
View raw message