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

Typo in java.util.Collections#synchronizedNavigableMap javadoc

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 21
    • 17, 20, 21
    • 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();

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

              Created:
              Updated:
              Resolved: