harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "spark shen (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-1161) [classlib][luni] java.util.TreeMap.subMap(Object, Object).size() throws unspecified NPE.
Date Mon, 14 Aug 2006 03:50:13 GMT
[classlib][luni] java.util.TreeMap.subMap(Object, Object).size() throws unspecified NPE.
----------------------------------------------------------------------------------------

                 Key: HARMONY-1161
                 URL: http://issues.apache.org/jira/browse/HARMONY-1161
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: spark shen


java.util.TreeMap.subMap(Object, Object).size() throws unspecified NPE under
certain case. Demonstrated below:

Code snippet:
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);
        }
    }

    public CollationKey getCollationKey(String arg0) {
        return null;
    }

    public int hashCode() {
        return 0;
    }

}

public void test_subMapLjava_lang_ObjectLjava_lang_Object() {
        TreeMap<String, String> map1 = new TreeMap<String, String>(new
MockComparatorNullTolerable ());
        map1.put("key1" , "value1");
        map1.put(null, "value1");
        SortedMap<String, String> subMap =  map1.subMap( null, "key1");
        assertEquals("Size of subMap should be 1:", 1, subMapWithNull.size());
}
When subMap.size() is called on Harmony, a NullPointerException will be thrown
out. But On RI, no such exception will be thrown out.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message