You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "spark shen (JIRA)" <ji...@apache.org> on 2006/08/01 10:27:13 UTC

[jira] Created: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

[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


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

        

[jira] Commented: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

Posted by "Stepan Mishura (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1026?page=comments#action_12425122 ] 
            
Stepan Mishura commented on HARMONY-1026:
-----------------------------------------

I agree with Natan here - the patch should correspond to the issue description.

Also the test case in the description looks suspicious for me - the method MockComparator.compare(T o1, T o2)  doesn't follow the spec for Comparator.compare(T o1, T o2).

Thanks,
Stepan.

> [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.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

        

[jira] Commented: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

Posted by "Nathan Beyer (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1026?page=comments#action_12425109 ] 
            
Nathan Beyer commented on HARMONY-1026:
---------------------------------------

The attached patch contains changes to WeakHashMap, which isn't mentioned in this issue at all. Is that a mistake?

> [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.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

        

[jira] Commented: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

Posted by "spark shen (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1026?page=comments#action_12425142 ] 
            
spark shen commented on HARMONY-1026:
-------------------------------------

OK. I will create another JIRA on TreeMap.

Best regards,
Spark Shen

> [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.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

        

[jira] Updated: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

Posted by "spark shen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1026?page=all ]

spark shen updated HARMONY-1026:
--------------------------------

    Attachment: harmony-1026.diff

This patch fixes the problem mentioned. Would you please try the patch?

Best regards,
Spark Shen

> [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
>         Attachments: 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

        

[jira] Commented: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

Posted by "spark shen (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1026?page=comments#action_12425119 ] 
            
spark shen commented on HARMONY-1026:
-------------------------------------

Change to WeakHashMap is trival and deliberate. It changes some coding convention problems to make the code more perfect. 
1. Use StringBuilder to assemble string used in toString() method
2. move unnecessary 'else' clauses in WeakHashMap.HashIterator.next() method

Is that acceptable?

Best regards,
Spark Shen

> [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.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

        

[jira] Assigned: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1026?page=all ]

Paulex Yang reassigned HARMONY-1026:
------------------------------------

    Assignee: Paulex Yang

> [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.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

        

[jira] Closed: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
     [ 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

        

[jira] Commented: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1026?page=comments#action_12425139 ] 
            
Paulex Yang commented on HARMONY-1026:
--------------------------------------

I'm looking at the patch(sorry for late, struggled for hours with some mysterious hard disk problem), and I also agree with Nathan here, Spark, you may raise another separate JIRA on the WeakHashMap to make the modification explicit. So would you create another patch for TreeMap only?

> [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.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

        

[jira] Updated: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

Posted by "spark shen (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1026?page=all ]

spark shen updated HARMONY-1026:
--------------------------------

    Attachment: harmony-1026-TreeMap.diff

I have modified the MockComparator and removed content not relative  to TreeMap. Would you please try this patch
?
(harmony-1026-TreeMap.diff)

Best regards

> [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

        

[jira] Commented: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

Posted by "spark shen (JIRA)" <ji...@apache.org>.
    [ http://issues.apache.org/jira/browse/HARMONY-1026?page=comments#action_12426469 ] 
            
spark shen commented on HARMONY-1026:
-------------------------------------

Hi Paulex,
The patch looks fine. Thank you.

Best regards
Spark Shen

> [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

        

[jira] Resolved: (HARMONY-1026) [classlib][luni] java.util.TreeMap.headMap(Object) method does not return empty SortedMap

Posted by "Paulex Yang (JIRA)" <ji...@apache.org>.
     [ http://issues.apache.org/jira/browse/HARMONY-1026?page=all ]

Paulex Yang resolved HARMONY-1026.
----------------------------------

    Resolution: Fixed

Spark, patch applied at revision r428619, thanks a lot for this enhancement, please verify that the problem is fully fixed as you expected.


> [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