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

FilteredList: null predicate should be allowed and indicate no filtering

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8u40
    • Fix Version/s: 8u40
    • Component/s: javafx
    • Environment:

      8u40b12

    • Subcomponent:

      Description

      FilteredList throws IllegalArgumentException when setting null predicate (see below). At the very least it must be document (which would be the easy way out).

      On the other hand, it has a constructor without predicate that's explicitly documented to be meant for binding: in such contexts, a null is hard to avoid. And not really necessary: instead of throwing, it might default to ALWAYS (pending documentation) and log the conversion, just as f.i. IntegerProperty does.

              ObservableList<String> list = createObservableList(true);
              // needs a predicate
              FilteredList<String> filtered = list.filtered(p -> false);
              filtered.setPredicate(null);
       
      Caused by: java.lang.IllegalArgumentException: Predicate cannot be null.
      at javafx.collections.transformation.FilteredList$1.invalidated(FilteredList.java:100)
      at javafx.beans.property.ObjectPropertyBase.markInvalid(ObjectPropertyBase.java:111)
      at javafx.beans.property.ObjectPropertyBase.set(ObjectPropertyBase.java:146)
      at javafx.collections.transformation.FilteredList.setPredicate(FilteredList.java:127)

        Attachments

          Activity

            People

            Assignee:
            vadim Vadim Pakhnushev
            Reporter:
            fastegal Jeanette Winzenburg
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported: