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

ListPropertyBase: fires invalid change on setting empty list

    XMLWordPrintable

Details

    Description

      ListChangeEvent.Change is documented to:

      " The Change may consist of one or more actual changes and must be iterated by next() method. Each change must be one of the following: [wasPremutated, wasAdded, wasRemoved, wasUpdated]"

      This contract is violated when setting an empty list to a property with null/empty list as value.

          @Test
          public void testListPropertyChangeOnSetEmptyToEmpty() {
              ListProperty listProperty = new SimpleListProperty(FXCollections.observableArrayList());
              ListChangeReport report = new ListChangeReport(listProperty);
              listProperty.set(FXCollections.observableArrayList());
              Change c = report.getLastChange();
              while(c.next()) {
                  boolean type = c.wasAdded() || c.wasRemoved() || c.wasPermutated() || c.wasUpdated();
                  assertTrue("at least one of the change types must be true", type);
              }
          }
          @Test
          public void testListPropertyChangeOnSetEmptyToNull() {
              ListProperty listProperty = new SimpleListProperty();
              ListChangeReport report = new ListChangeReport(listProperty);
              listProperty.set(FXCollections.observableArrayList());
              Change c = report.getLastChange();
              while(c.next()) {
                  boolean type = c.wasAdded() || c.wasRemoved() || c.wasPermutated() || c.wasUpdated();
                  assertTrue("at least one of the change types must be true", type);
              }
          }

      Attachments

        Activity

          People

            Unassigned Unassigned
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Imported: