You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by hi...@apache.org on 2010/02/17 21:34:54 UTC

svn commit: r911169 - /harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeMap.java

Author: hindessm
Date: Wed Feb 17 20:34:53 2010
New Revision: 911169

URL: http://svn.apache.org/viewvc?rev=911169&view=rev
Log:
Reinstate change r903454 which adds null pointer exceptions to toComparable
helper.
Fix some query methods to return null if map is empty regardless of
parameters.

Modified:
    harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeMap.java

Modified: harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeMap.java
URL: http://svn.apache.org/viewvc/harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeMap.java?rev=911169&r1=911168&r2=911169&view=diff
==============================================================================
--- harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeMap.java (original)
+++ harmony/enhanced/classlib/branches/java6/modules/luni/src/main/java/java/util/TreeMap.java Wed Feb 17 20:34:53 2010
@@ -4044,6 +4044,9 @@
     }
 
     TreeMap.Entry<K, V> findCeilingEntry(K key) {
+        if (root == null) {
+            return null;
+        }
         Comparable<K> object = comparator == null ? toComparable((K) key)
                 : null;
         K keyK = (K) key;
@@ -4105,6 +4108,9 @@
     }
 
     TreeMap.Entry<K, V> findFloorEntry(K key) {
+        if (root == null) {
+            return null;
+        }
         Comparable<K> object = comparator == null ? toComparable((K) key)
                 : null;
         K keyK = (K) key;
@@ -4164,7 +4170,10 @@
         return null;
     }
 
-    TreeMap.Entry<K, V> findLowerEntry(K key) {        
+    TreeMap.Entry<K, V> findLowerEntry(K key) {
+        if (root == null) {
+            return null;
+        }
         Comparable<K> object = comparator == null ? toComparable((K) key)
                 : null;
         K keyK = (K) key;
@@ -4219,6 +4228,9 @@
     }
 
     TreeMap.Entry<K, V> findHigherEntry(K key) {
+        if (root == null) {
+            return null;
+        }
         Comparable<K> object = comparator == null ? toComparable((K) key)
                 : null;
         K keyK = (K) key;
@@ -5465,6 +5477,9 @@
 
     @SuppressWarnings("unchecked")
     private static <T> Comparable<T> toComparable(T obj) {
+        if (obj == null) {
+            throw new NullPointerException();
+        }
         return (Comparable<T>) obj;
     }