ConcurrentHashMap.entrySet().iterator() can return entry with never-existent value

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P3
    • 6
    • Affects Version/s: 6
    • Component/s: core-libs
    • b51
    • generic
    • generic
    • Verified

      This program

      ------------------------------------------------------------
      import java.util.*;
      import java.util.concurrent.*;

      public class Bug {
          public static void main(String[] args) throws Exception {
      Map m = new ConcurrentHashMap();
      m.put(1,2);
      Iterator it = m.entrySet().iterator();
      if (it.hasNext()) {
      m.remove(1); // sneaky
      System.out.println(it.next());
      }
          }
      }
      ------------------------------------------------------------
      prints

      1=null

      which is very surprising, since 1 was never mapped to null,
      and in fact, it could never be.

            Assignee:
            Martin Buchholz
            Reporter:
            Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: