-
Bug
-
Resolution: Fixed
-
P4
-
8u20
-
Windows 8.1 64bit, JDK 8u20-b17
Here is a sample (code below too):
https://gist.github.com/ryanjaeb/841bb08c0c5fa1bea946
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
public class FilteredListWithoutPredicate {
public static void main(String[] args) {
ObservableList<String> source = FXCollections.observableArrayList();
source.addAll("one", "two", "three");
System.out.println("source size: " + source.size());
System.out.println("without predicate: "
+ new FilteredList<>(source).size());
System.out.println("with predicate: "
+ new FilteredList<>(source, t -> true).size());
}
}
Steps to reproduce:
1. Run the example.
2. Observe the output.
The output will be:
source size: 3
without predicate: 0
with predicate: 3
This contradicts the JavaDoc for the one arg constructor of FilteredList.
The default value for the predicate property in FilteredList is the ALWAYS_TRUE predicate. The one arg constructor passes ALWAYS_TRUE as the predicate, but, since it's already ALWAYS_TRUE, the predicate property won't be invalidated.
Passing a different instance of an always true predicate is a really simple workaround.
https://gist.github.com/ryanjaeb/841bb08c0c5fa1bea946
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.collections.transformation.FilteredList;
public class FilteredListWithoutPredicate {
public static void main(String[] args) {
ObservableList<String> source = FXCollections.observableArrayList();
source.addAll("one", "two", "three");
System.out.println("source size: " + source.size());
System.out.println("without predicate: "
+ new FilteredList<>(source).size());
System.out.println("with predicate: "
+ new FilteredList<>(source, t -> true).size());
}
}
Steps to reproduce:
1. Run the example.
2. Observe the output.
The output will be:
source size: 3
without predicate: 0
with predicate: 3
This contradicts the JavaDoc for the one arg constructor of FilteredList.
The default value for the predicate property in FilteredList is the ALWAYS_TRUE predicate. The one arg constructor passes ALWAYS_TRUE as the predicate, but, since it's already ALWAYS_TRUE, the predicate property won't be invalidated.
Passing a different instance of an always true predicate is a really simple workaround.