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

small errors in ConcurrentHashMap and LongAdder docs

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 9
    • None
    • core-libs

    Description

      The class doc for j.u.c.atomic.LongAdder has an incorrect example. The call to computeIfAbsent has the wrong number of arguments.

      Suggested patch:

      diff -r 79a6703ab839 src/share/classes/java/util/concurrent/atomic/LongAdder.java
      --- a/src/share/classes/java/util/concurrent/atomic/LongAdder.java Thu May 29 15:50:36 2014 +0100
      +++ b/src/share/classes/java/util/concurrent/atomic/LongAdder.java Fri May 30 16:11:03 2014 -0700
      @@ -57,7 +57,7 @@
        * frequency map (a form of histogram or multiset). For example, to
        * add a count to a {@code ConcurrentHashMap<String,LongAdder> freqs},
        * initializing if not already present, you can use {@code
      - * freqs.computeIfAbsent(k -> new LongAdder()).increment();}
      + * freqs.computeIfAbsent(key, k -> new LongAdder()).increment();}
        *
        * <p>This class extends {@link Number}, but does <em>not</em> define
        * methods such as {@code equals}, {@code hashCode} and {@code

      Attachments

        Issue Links

          Activity

            People

              smarks Stuart Marks
              smarks Stuart Marks
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: