JDK-8093278 : FitleredList: incorrect initial state with batch and reject-all matcher
  • Type: Bug
  • Component: javafx
  • Sub-Component: base
  • Affected Version: fx2.0
  • Priority: P5
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2011-07-25
  • Updated: 2015-07-21
  • Resolved: 2013-05-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8Fixed
Related Reports
Blocks :  
Blocks :  
Description

    private static class Always implements Matcher<Integer> {
        
        @Override
        public boolean matches(Integer i) {
            return true;
        }
    }
    
    private static class Never implements Matcher<Integer> {
        
        @Override
        public boolean matches(Integer i) {
            return false;
        }
    }
    
    /**
     * Matcher rejecting all: strange behaviour in batch mode
     */
    @Test
    public void testFilteredKeepNoneBatch() {
        ObservableList<Integer> original = FXCollections.observableArrayList(
                0, 1, 2, 3, 4 ,5, 6, 7, 8, 9
        );
        FilteredList list = new FilteredList(original, new Never(), FilterMode.BATCH);
        list.filter();
        assertEquals("must have null size, matcher rejects all " + list, 0, list.size());
    }

    /**
    * okay if set after some filtering has happened
    */
    @Test
    public void testFilteredBatchChangeMatcher() {
        ObservableList<Integer> original = FXCollections.observableArrayList(
               0, 1, 2, 3, 4 ,5, 6, 7, 8, 9
        );
        FilteredList list = new FilteredList(original, new Always(), FilterMode.BATCH);
        list.filter();
        assertEquals(original.size(), list.size());
        list.setMatcher(new Never());
        list.filter();
        assertEquals(0, list.size());
        
    }

    /**
     * Filter okay in Live mode
     */
    @Test
    public void testFilteredKeepNoneLive() {
        ObservableList<Integer> original = FXCollections.observableArrayList(
                0, 1, 2, 3, 4 ,5, 6, 7, 8, 9
        );
        FilteredList list = new FilteredList(original, new Never());
        assertEquals(0, list.size());
    }
    


Comments
Verified for 8.0 b122
07-01-2014

Fixed in the new implementation (RT-17053)
07-05-2013

Reducing priority and moving to Lombard, because FilteredList is going to be removed from the public API.
04-08-2011