Uploaded image for project: 'UIMA'
  1. UIMA
  2. UIMA-4728

Int2IntHashMap bug in containsKey()

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.8.1SDK
    • 2.9.0SDK
    • Core Java Framework
    • None

    Description

      There is a bug in containsKey() in the Int2IntHashMap. Use this test to check for the bug:

      import java.util.HashMap;
      import java.util.Map;
      import org.apache.uima.internal.util.Int2IntHashMap;
      import org.junit.Test;
      
          @Test
          public void int2intTest()
          {
              Int2IntHashMap map1 = new Int2IntHashMap();
              
              Map<Integer, Integer> map2 = new HashMap<Integer, Integer>();
              
              for (int i = 1; i < 100; i++) {
                  map1.put(i, 100-1);
                  map2.put(i, 100-1);
              }
      
              for (int i = 1; i < 100; i++) {
                  assertTrue("Map does not contain key ["+i+"]", map2.containsKey(i));
              }
              
              System.out.println("Reference map implementation ok.");
      
              for (int i = 1; i < 100; i++) {
                  assertTrue("Map does not contain key ["+i+"]", map1.containsKey(i));
              }
              
              System.out.println("UIMA map implementation ok.");
          }
      

      Fails with:

      java.lang.AssertionError: Map does not contain key [65]
      

      Attachments

        Activity

          People

            schor Marshall Schor
            rec Richard Eckart de Castilho
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: