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

java.util.Observable Javadoc misstates order of notification

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 8u192
    • Fix Version/s: None
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      x86_64
    • OS:
      windows_10

      Description

      ADDITIONAL SYSTEM INFORMATION :
      Windows 10/ JDK 8, issue still exists in OpenJDK 10/11

      A DESCRIPTION OF THE PROBLEM :
      Javadoc states "The default implementation provided in the Observable class will notify Observers in the order in which they registered interest". However the actual implementation iterates the array in reverse order.

      While this is qualified by a prior statement that contractually order is unspecified, it is still confusing & erroneous.

      Recommended fix:
      - While forward order of notification would seem logically preferable, changing the ordering in the implementation would likely be impactful and break compatibility.
      - Therefore it would likely be preferable to correct the documentation, to state that the default implementation delivered notifications "in the reverse order to which they registered interest".


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1) Check the Observable Javadoc to see it states "The default implementation provided in the Observable class will notify Observers in the order in which they registered interest".
      2) Check Observable.notifyObservers (Object) implementation for code which notifies observes in reverse of the documented order:
              for (int i = arrLocal.length-1; i>=0; i--)
                  ((Observer)arrLocal[i]).update(this, arg);

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Javadoc should state that default implementation delivers notification in reverse order.
      ACTUAL -
      Javadoc incorrectly states that default implementation delivers notification in order that they registered interest.

      FREQUENCY : always


        Attachments

          Activity

            People

            • Assignee:
              psonal Pallavi Sonal
              Reporter:
              webbuggrp Webbug Group
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: