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

ConcurrentModificationException in nested HashMap.computeIfAbsent calls

XMLWordPrintable

    • b59
    • 9
    • generic
    • generic

      A DESCRIPTION OF THE PROBLEM :
      Nested calls to computeIfAbsent result in ConcurrentModificationException

      REGRESSION : Last worked in version 8u172


      ---------- BEGIN SOURCE ----------
        public static void main(String[] args) {
              // dep2 depends on dep1
              Map<String, String> cache = new HashMap<>();
              cache.computeIfAbsent("dep2", ignored -> {
                  cache.computeIfAbsent("dep1", ignored2 -> "dep1_value");
                  return "dep2_value";
              });
              System.out.println(cache.get("dep1"));
              System.out.println(cache.get("dep2"));
          }
      ---------- END SOURCE ----------

      FREQUENCY : always


            Unassigned Unassigned
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: