harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From py...@apache.org
Subject svn commit: r431540 - in /incubator/harmony/enhanced/classlib/trunk/modules/luni/src: main/java/java/util/TreeMap.java test/java/tests/api/java/util/TreeMapTest.java
Date Tue, 15 Aug 2006 06:18:39 GMT
Author: pyang
Date: Mon Aug 14 23:18:39 2006
New Revision: 431540

URL: http://svn.apache.org/viewvc?rev=431540&view=rev
Log:
Patch applied for HARMONY-1161 ([classlib][luni] java.util.TreeMap.subMap(Object, Object).size()
throws unspecified NPE.)

Modified:
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java
    incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java?rev=431540&r1=431539&r2=431540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/util/TreeMap.java
Mon Aug 14 23:18:39 2006
@@ -186,7 +186,7 @@
             
             @Override
             public boolean hasNext() {
-                return (node != null) && (cmp.compare(endKey, node.key) > 0);
+                return (node != null) && (cmp.compare( node.key, endKey ) < 0);
             }
         }
 

Modified: incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java
URL: http://svn.apache.org/viewvc/incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java?rev=431540&r1=431539&r2=431540&view=diff
==============================================================================
--- incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java
(original)
+++ incubator/harmony/enhanced/classlib/trunk/modules/luni/src/test/java/tests/api/java/util/TreeMapTest.java
Mon Aug 14 23:18:39 2006
@@ -54,6 +54,20 @@
             return c1.compareTo(c2);
         }
     }
+    
+    // Regression for Harmony-1161
+    class MockComparatorNullTolerable implements Comparator<String> {
+
+        public int compare(String o1, String o2) {
+            if( o1 == o2 ) {
+                return 0;
+            }
+            if( null == o1 ) {
+                return -1;
+            }
+            return o1.compareTo(o2);
+        }
+    }
 
 	TreeMap tm;
 
@@ -367,6 +381,13 @@
 		}
 		assertEquals("end key less than start key should throw IllegalArgumentException",
 				1, result);
+        
+        // Regression for Harmony-1161
+        TreeMap<String, String> treeMapWithNull = new TreeMap<String, String>(new
MockComparatorNullTolerable());
+        treeMapWithNull.put("key1" , "value1"); //$NON-NLS-1$ //$NON-NLS-2$
+        treeMapWithNull.put(null, "value2"); //$NON-NLS-1$
+        SortedMap<String, String> subMapWithNull =  treeMapWithNull.subMap( null, "key1");
//$NON-NLS-1$
+        assertEquals("Size of subMap should be 1:", 1, subMapWithNull.size()); //$NON-NLS-1$
 	}
 
 	/**



Mime
View raw message