NoSuchElementException on ColumnFilter change

Issue #704 new
Justin Raabe
created an issue

Using 8.40.12, we're getting a NoSuchElementException when doing any remove or change operations on filter.getBackingList(). It looks to be the same issue as Issue 691, where there's just an unchecked .get() in ColumnFilter.java

Exception in thread "Thread-118" java.util.NoSuchElementException: No value present
at java.util.Optional.get(Optional.java:135)
at impl.org.controlsfx.table.ColumnFilter.removeBackingItem(ColumnFilter.java:187)
at impl.org.controlsfx.table.ColumnFilter.lambda$null$138(ColumnFilter.java:217)
at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1374)
at java.util.stream.ReferencePipeline$Head.forEach(ReferencePipeline.java:580)
at impl.org.controlsfx.table.ColumnFilter.lambda$initializeListeners$139(ColumnFilter.java:217)
at com.sun.javafx.collections.ListListenerHelper$Generic.fireValueChangedEvent(ListListenerHelper.java:329)
at com.sun.javafx.collections.ListListenerHelper.fireValueChangedEvent(ListListenerHelper.java:73)
at javafx.collections.ObservableListBase.fireChange(ObservableListBase.java:233)
at javafx.collections.ListChangeBuilder.commit(ListChangeBuilder.java:524)
at javafx.collections.ListChangeBuilder.endChange(ListChangeBuilder.541)
at javafx.collections.ObservableListBase.endChange(ObservableListBase.java:205)
at com.sun.javafx.collections.ObservableListWrapper.removeAll(ObservableListWrapper.java:185)
at (our code which calls filter.getBackingList().removeAll(list))

The code in question:

            // Remove the FilterValue associated with the value
            FilterValue<T,R> existingFilterValue = getFilterValues().stream()
                    .filter(fv -> Objects.equals(fv.getValue(), value)).findAny().get();

Which I think could just be fixed with a .orElse(null); instead of the get();

Comments (2)

  1. Thomas Nield

    I just encountered this error a few times too. I have a strong idea what the issue is and it shouldn't be hard to fix (I'm getting a value from an Optional without checking if it is present). I'll get to this as soon as I can.

  2. Log in to comment