changeset 7331:c367a3e860f2

RT-37668 FilteredList reports a size of zero until a Predicate is supplied.
author Martin Sladecek <martin.sladecek@oracle.com>
date Tue, 24 Jun 2014 15:35:19 +0200
parents 451301b279ed
children 1f068eb07b58
files modules/base/src/main/java/javafx/collections/transformation/FilteredList.java modules/base/src/test/java/javafx/collections/FilteredListTest.java
diffstat 2 files changed, 16 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/modules/base/src/main/java/javafx/collections/transformation/FilteredList.java	Mon Jun 23 20:04:23 2014 -0700
+++ b/modules/base/src/main/java/javafx/collections/transformation/FilteredList.java	Tue Jun 24 15:35:19 2014 +0200
@@ -88,17 +88,17 @@
      * Elements not matching the predicate will be filtered-out.
      */
     private final ObjectProperty<Predicate<? super E>> predicate =
-            new ObjectPropertyBase<Predicate<? super E>>(ALWAYS_TRUE) {
+            new ObjectPropertyBase<Predicate<? super E>>() {
 
         @Override
         protected void invalidated() {
             if (get() == null) {
                 if (isBound()) {
                     unbind();
-                    set(ALWAYS_TRUE);
-                    throw new IllegalArgumentException("Predicate cannot be null.");
+                }
+                set(ALWAYS_TRUE);
+                throw new IllegalArgumentException("Predicate cannot be null.");
 
-                }
             }
             refilter();
         }
--- a/modules/base/src/test/java/javafx/collections/FilteredListTest.java	Mon Jun 23 20:04:23 2014 -0700
+++ b/modules/base/src/test/java/javafx/collections/FilteredListTest.java	Tue Jun 24 15:35:19 2014 +0200
@@ -137,6 +137,18 @@
         assertEquals(Arrays.asList(createPerson("AA")), filtered);
     }
 
+    @Test(expected = IllegalArgumentException.class)
+    public void testNullPredicate() {
+        filteredList.setPredicate(null);
+    }
+
+    @Test
+    public void testSingleArgConstructor() {
+        filteredList = new FilteredList<>(list);
+        assertEquals(list.size(), filteredList.size());
+        assertEquals(list, filteredList);
+    }
+
     private Person createPerson(String name) {
         Person p =  new Person();
         p.name.set(name);