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

FilteredList doesn't filter correctly

    XMLWordPrintable

Details

    Description

      I create a FilteredList f in Batch-Mode on a list of strings and have its matcher always returning false. I then look at f and see it contains all elements. Then I call filter() on f and check its contents again: every second item is missing. I call filter again and again every second item is missing. For example, I have this code (Clojure here):
      (def f (FilteredList. ["Anna" "Carl" "Jeff" "Bob" "Bill" "Tim"]
                            (reify Matcher (matches [_ e] false))
                            FilterableList$FilterMode/BATCH))

      f ==> #<FilteredList [Anna, Carl, Jeff, Bob, Bill, Tim]>

      Then: (.filter f)

      f ==> #<FilteredList [Carl, Bob, Tim]>

      Now again: (.filter f)

      f ==> #<FilteredList [Bob]>

      Last time I (.filter f)

      f ==> #<FilteredList []>

      I expected that last result in the first step.
      And btw as a side note: what I also did not expect is that calling filter actually mutates the list and deletes the filtered elements.
      I thought that a FilteredList provides a filtered view on my data. Instead it seems the FilteredList creates a copy and destructively changes it. I am not sure that this is intended and the current implementation simply contains a bug. Please let me know about it, because then I can file either a bug or a feature request, thanks.

      Attachments

        Activity

          People

            msladecek Martin Sládeček
            athiemejfx Andre Thieme (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported: