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

FilteredList: ArrayIndexOutOfBoundsException when used with extractor

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • 8u60
    • 8u40
    • javafx
    • 8.0.40-ea-b19

      When using a FilteredList generated from an ObservableList with an extractor, I get an ArrayIndexOutOfBoundsException (with 8.0.40-ea-b19):

      Seems only to be the case when the filter returns false. Test case is below.

      Exception in thread "JavaFX Application Thread" java.lang.ArrayIndexOutOfBoundsException
      at java.lang.System.arraycopy(Native Method)
      at javafx.collections.transformation.FilteredList.updateFilter(FilteredList.java:303)
      at javafx.collections.transformation.FilteredList.update(FilteredList.java:244)
      at javafx.collections.transformation.FilteredList.sourceChanged(FilteredList.java:142)
      at javafx.collections.transformation.TransformationList.lambda$getListener$15(TransformationList.java:106)
      at javafx.collections.transformation.TransformationList$$Lambda$80/989932913.onChanged(Unknown Source)
      at javafx.collections.WeakListChangeListener.onChanged(WeakListChangeListener.java:88)
      at com.sun.javafx.collections.ListListenerHelper$SingleChange.fireValueChangedEvent(ListListenerHelper.java:164)
      at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
      at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
      at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:485)
      at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.java:541)
      at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
      at com.sun.javafx.collections.ObservableListWrapper.access$200(ObservableListWrapper.java:45)
      at com.sun.javafx.collections.ObservableListWrapper$1$1.invalidated(ObservableListWrapper.java:75)
      at com.sun.javafx.binding.ExpressionHelper$SingleInvalidation.fireValueChangedEvent(ExpressionHelper.java:137)
      at com.sun.javafx.binding.ExpressionHelper.fireValueChangedEvent(ExpressionHelper.java:81)
      at javafx.beans.property.StringPropertyBase.fireValueChangedEvent(StringPropertyBase.java:103)
      at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:110)
      at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:144)
      at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:49)





      import javafx.application.Application;
      import javafx.beans.Observable;
      import javafx.beans.property.SimpleStringProperty;
      import javafx.beans.property.StringProperty;
      import javafx.collections.FXCollections;
      import javafx.collections.ObservableList;
      import javafx.scene.Scene;
      import javafx.scene.control.Button;
      import javafx.scene.control.ListView;
      import javafx.scene.layout.VBox;
      import javafx.stage.Stage;

      public class TestApp2 extends Application {

          public static void main(String[] args) {
              launch(args);
          }

          @Override
          public void start(final Stage stage) throws Exception {

              // I want the ListView to be updated, whenever stringProperty changes.
              ObservableList<Item> itemsList = FXCollections.observableArrayList(param -> new Observable[]{param.stringProperty});
              Item item = new Item();
              itemsList.add(item);

              ListView<Item> listView = new ListView<>();
              listView.setItems(itemsList.filtered((t) -> false)); // With true, it works as expected

              Button button = new Button("Click Me");
              button.setOnAction((e) -> item.stringProperty.set("new Value"));

              Scene scene = new Scene(new VBox(listView, button));
              stage.setScene(scene);
              stage.show();

          }

          private static class Item {
              private StringProperty stringProperty = new SimpleStringProperty();

              @Override
              public String toString() {
                  return stringProperty.get();
              }
          }
      }

            vadim Vadim Pakhnushev
            cschudtjfx Christian Schudt (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: