You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Paulex Yang (JIRA)" <ji...@apache.org> on 2006/08/09 04:09:18 UTC
[jira] Closed: (HARMONY-1026) [classlib][luni]
java.util.TreeMap.headMap(Object) method does not return empty SortedMap
[ http://issues.apache.org/jira/browse/HARMONY-1026?page=all ]
Paulex Yang closed HARMONY-1026.
--------------------------------
Verified by Spark.
> [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap
> -----------------------------------------------------------------------------------------
>
> Key: HARMONY-1026
> URL: http://issues.apache.org/jira/browse/HARMONY-1026
> Project: Harmony
> Issue Type: Bug
> Components: Classlib
> Reporter: spark shen
> Assigned To: Paulex Yang
> Attachments: harmony-1026-TreeMap.diff, harmony-1026.diff
>
>
> java.util.TreeMap.headMap(Object) method does not return
> empty SortedMap when the specified object is null and the tree map uses a
> null-tolerable comparator.
> The following test case gives a hint.
> public static class MockComparator<T> implements Comparator<T> {
>
> public int compare(T o1, T o2) {
> if(null == o1) return -1;
> if(o1.equals(o2)) {
> return 0;
> }
> return 1;
> }
>
> }
> public void test_headMapLjava_lang_Object() {
> TreeMap<Integer, Double> map = new TreeMap<Integer, Double>(
> new MockComparator<Integer>());
> map.put(1, 2.1);
> map.put(2, 3.1);
> map.put(3, 4.5);
> map.put(7, 21.3);
> SortedMap<Integer, Double> smap = map.headMap(null);
> assertEquals(0, smap.size());
> Set<Integer> keySet = smap.keySet();
> assertEquals(0, keySet.size());
> Set<Map.Entry<Integer, Double>> entrySet = smap.entrySet();
> assertEquals(0, entrySet.size());
> }
> I will attach a patch to fix this problem.
> Best regards,
> Spark Shen
--
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