harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yang Wang (Created) (JIRA)" <j...@apache.org>
Subject [jira] [Created] (HARMONY-6688) TreeMap returns wrong key in lastKey function through interface SortedMap
Date Tue, 11 Oct 2011 10:27:12 GMT
TreeMap returns wrong key in lastKey function through interface SortedMap
-------------------------------------------------------------------------

                 Key: HARMONY-6688
                 URL: https://issues.apache.org/jira/browse/HARMONY-6688
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
    Affects Versions: 5.0M15, 6.0M4
         Environment: Platform independent
            Reporter: Yang Wang
             Fix For: 6.0M4, 5.0M16


Problem
=======
TreeMap returns wrong key in lastKey function through interface SortedMap when the map size
is 65 and submap size is 64.

Test to reproduce the error
===================
import java.util.*;

public class Main {

    static TreeMap<Integer,Integer> map;

    static boolean test_passed = true;


    public static void test_lastKey() {
        SortedMap<Integer,Integer> s_map;

        for(int i=0; i<65; i++)
          map.put(i, i);

          s_map = map.subMap(0, 64);

          int last_key = s_map.lastKey();
          if (last_key != 63) {
            test_passed = false;
            System.out.println("Error occured for map size: " + 65 + " submap(0, " + 64 +
")");
          }
        map.clear();
    }


    public static void main(String args[])
    {
        map = new TreeMap<Integer,Integer>();
        System.out.println("test started!");

        test_lastKey();

        if (test_passed) System.out.println("test passed!");
    }

}

Proposed fix
==========
Search the string "foundIndex = foundNode.right_idx - 1" in TreeMap.java,
and change it to "foundIndex = foundNode.right_idx".

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message