Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8080587

HashMap bug on put

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.7.0_79"
      Java(TM) SE Runtime Environment (build 1.7.0_79-b15)
      Java HotSpot(TM) 64-Bit Server VM (build 24.79-b02, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Windows 8.1 64bit

      A DESCRIPTION OF THE PROBLEM :
      If I insert a record with:
      key "02" and value "XXXX"
      key "11" and value "XXXX"

      The last key "11" replace the Entry with key "02"

      Attention: after to string appear all maps with correct value, but If you do a for or use the debug appear a different situation.

      REGRESSION. Last worked in version 6u45

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Debug the source code in attachment

      ACTUAL -
      Debug or for show all value except "02" (because It's replaced by "11")

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      no exceptions

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------

      import java.util.HashMap;
      import java.util.Map;


      public class Main {

      public static void main(String[] args) {

      Map<String, String> maps = new HashMap<String, String>();

      maps.put("01", "be54btr");

      maps.put("02", "be54bertr");

      maps.put("03", "beh54btr");

      maps.put("04", "be546btr");

      maps.put("05", "be544btr");

      maps.put("06", "be54bjtr");

      maps.put("07", "beshbtr");

      maps.put("08", "bekkkktr");

      maps.put("09", "be5sssbtr");

      maps.put("10", "be235235tr");

      maps.put("11", "be5475vvvbtr");

      maps.put("12", "ccc475vvvbtr");

      maps.toString();

      }

      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      (only for String Key)
      Check each char into old and new key.

            pardesha Pardeep Sharma
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: