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

Wrong variable used in java.util.Collections javadoc code

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 7u51, 9
    • Fix Version/s: 9
    • Component/s: core-libs

      Description

      A DESCRIPTION OF THE PROBLEM :
      In the second code example of <code>Collections.synchronizedSortedMap</code> is the variable <code>s</code> and not <code>s2</code> used.

      That's not really a problem. :-) But I hope I can make the documentation better.

      Greetings
      Markus Wolf

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      synchronizedSortedMap

            ...
        Set s2 = m2.keySet(); // Needn't be in synchronized block
            ...
        synchronized (m) { // Synchronizing on m, not m2 or s2!
            Iterator i = s2.iterator(); // Must be in synchronized block
            ...
      ACTUAL -
      synchronizedSortedMap

            ...
        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
            ...

      URL OF FAULTY DOCUMENTATION :
      http://docs.oracle.com/javase/7/docs/api/java/util/Collections.html#synchronizedSortedMap%28java.util.SortedMap%29

        Attachments

          Activity

            People

            Assignee:
            rriggs Roger Riggs
            Reporter:
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: