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

If multiple ChangeListener are added on ListProperty and one of them fail, others will not be fired

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Duplicate
    • Affects Version/s: 8, 9
    • Fix Version/s: None
    • Component/s: javafx
    • Subcomponent:
    • CPU:
      x86
    • OS:
      other

      Description

      FULL PRODUCT VERSION :
      java version "1.8.0_121"
      Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
      Java HotSpot(TM) Client VM (build 25.121-b13, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows [version 10.0.14393]

      A DESCRIPTION OF THE PROBLEM :
      If multiple ChangeListener are added to a non-map/list property (StringProperty for instance). Then all ChangeListener will be called if the value of the string property change. EVEN if one of them fails with an uncaught exception.

      But in the case where multiple ChangeListener are added to a ListProperty (or MapProperty) if one of them fail then other listeners will not be called.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      - Instanciate a ListProperty
      - Add two changeListener
      - Throw an exception from the first one
      - Check that the second one will not be called

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The second listener should be called, even if the previous one fails
      ACTUAL -
      The second listener is never called

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javafx.beans.property.ListProperty;
      import javafx.beans.property.SimpleListProperty;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.property.StringProperty;
      import javafx.collections.FXCollections;

      public class ListenerExceptionsTest {

          private static class Project {
              public ListProperty<String> listProperty = new SimpleListProperty<>(FXCollections.observableArrayList());
              public StringProperty stringProperty = new SimpleStringProperty();
          }

          public static void main(String[] args) {
              Project project = new Project();

              project.listProperty.addListener((observable, oldValue, newValue) -> {
                  System.out.println("First list listener");
                  throw new NullPointerException();
              });
              project.listProperty.addListener((observable, oldValue, newValue) -> {
                  System.out.println("Second list listener");
              });
              project.listProperty.add("LIST_STRING");

              project.stringProperty.addListener((observable, oldValue, newValue) -> {
                  System.out.println("First string listener");
                  throw new NullPointerException();
              });
              project.stringProperty.addListener((observable, oldValue, newValue) -> {
                  System.out.println("Second string listener");
              });
              project.stringProperty.set("STRING");
          }
      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                pmangal Priyanka Mangal (Inactive)
                Reporter:
                webbuggrp Webbug Group
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: