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

improve DelayQueue removal method javadoc

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 21
    • 19.0.2
    • core-libs
    • b17
    • generic
    • generic
    • Verified

      The documentation for java.util.concurrent.DelayQueue states:

      "The head of the queue is that Delayed element whose delay expired furthest in the past. If no delay has expired there is no head and poll will return null."

      However the documentation for the peek() method states:

      "Retrieves, but does not remove, the head of this queue, or returns null if this queue is empty. Unlike poll, if no expired elements are available in the queue, this method returns the element that will expire next, if one exists."

      With a return value documented as: "the head of this queue, or null if this queue is empty"

      I believe the wording that states "If no delay has expired there is no head..." is confusing and inconsistent with the documentation for peek().

            martin Martin Buchholz
            swpalmer Scott Palmer
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: