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

Wrong sublist used in ListChangeListener

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • jfx21
    • jfx11, 8, 9
    • javafx
    • 8
    • b05

    Description

      Found while randomly looking at the code:

      In AccordionBehavior:280, the body of ListChangeListener uses getAddedSubList() while processing removed elements:

      ```
              private final ListChangeListener<TitledPane> panesListener = c -> {
                  while (c.next()) {
                      if (c.wasAdded()) {
                          for (final TitledPane tp: c.getAddedSubList()) {
                              tp.focusedProperty().addListener(paneFocusListener);
                          }
                      } else if (c.wasRemoved()) {
                          for (final TitledPane tp: c.getAddedSubList()) {
                              tp.focusedProperty().removeListener(paneFocusListener);
                          }
                      }
                  }
              };
      ```

      This looks like a copy-paste bug which was introduced by RT-32103 / JDK-8123765 on 2013/08/02.

      We'd need to check if a similar pattern has been used elsewhere (may be create a script or a regex pattern?)

      EDIT: Regex pattern used in Eclipse
      (?s)wasRemoved.*getAddedSubList

      identified the following places:
      AccordionBehavior:280
      Rule:269

      And the other way around
      (?s)wasAdded.*getRemoved
      did not turn up any similar issues.

      Attachments

        Issue Links

          Activity

            People

              angorya Andy Goryachev
              angorya Andy Goryachev
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: