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

MappingChange returns true for wasAdded() when original event returns false

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 8u5
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Labels:
    • Subcomponent:

      Description

      package application;

      import com.sun.javafx.collections.MappingChange;
      import com.sun.javafx.collections.NonIterableChange;

      import javafx.collections.FXCollections;
      import javafx.collections.ListChangeListener;
      import javafx.collections.ObservableList;

      public class Main {
          
          public static void main(String[] args) {
              ObservableList<String> list1 = FXCollections.<String>observableArrayList();
              ObservableList<Object> list2 = FXCollections.<Object>observableArrayList();
              MappingChange.Map<String, Object> map = new MappingChange.Map<String, Object>() {

                  @Override
                  public Object map(String original) {
                      return "removedItem - map";
                  }
                  
              };
              
              ListChangeListener.Change<String> removedChange = new NonIterableChange.SimpleRemovedChange<String>(0, 1, "removedItem", list1) {
                  
                  @Override
                  // RT-37694
                  public boolean wasAdded() {
                      checkState();
                      
                      return false;
                  }
                  
              };
              
              MappingChange<String, Object> mappingChange = new MappingChange<String, Object>(removedChange, map, list2);
              try {
                  while(mappingChange.next())
                  {
                       System.err.println("change");
                       System.err.println("added " + mappingChange.wasAdded() + " - size:" + mappingChange.getAddedSize());
                       System.err.println("removed " + mappingChange.wasRemoved() + " - size:" + mappingChange.getRemovedSize());
                       System.err.println("replaced " + mappingChange.wasReplaced());
                       
                       System.err.println(mappingChange.getRemoved());
                       System.err.println(mappingChange.getAddedSubList());
                  }
              } catch(Throwable thr) {
                  thr.printStackTrace();
              }
          }
          
      }

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                msladecek Martin Sládeček
                Reporter:
                lvitasekjfx Lukas Vitasek (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported: