Typo in java.util.Collections#synchronizedNavigableMap javadoc

XMLWordPrintable

    • Type: Bug
    • Resolution: Fixed
    • Priority: P4
    • 21
    • Affects Version/s: 17, 20, 21
    • Component/s: core-libs

      Created for https://github.com/openjdk/jdk/pull/11679

         NavigableMap m = Collections.synchronizedNavigableMap(new TreeMap());
         NavigableMap m2 = m.subMap(foo, true, bar, false);
             ...
         Set s2 = m2.keySet(); // Needn't be in synchronized block
             ...
         synchronized (m) { // Synchronizing on m, not m2 or s2!
             Iterator i = s.iterator(); // Must be in synchronized block
             while (i.hasNext())
                 foo(i.next());
         }

      Should be
             Iterator i = s2.iterator();

            Assignee:
            Andrey Turbanov
            Reporter:
            Andrey Turbanov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: