JDK-8359020 : TabObservableList.reorder changes content of filtered list
  • Type: Bug
  • Component: javafx
  • Sub-Component: base
  • Affected Version: jfx24,jfx25
  • Priority: P4
  • Status: New
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2025-06-04
  • Updated: 2025-06-09
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.
Other
tbdUnresolved
Related Reports
Duplicate :  
Description
A DESCRIPTION OF THE PROBLEM :
base.reorder(x, y) changes content of a filteredList fl build on tabPane.getTabs()



STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Tab lib1 = new Tab("lib1");
Tab lib2 = new Tab("lib2");
Tab other = new Tab("other");

TabPane tabPane = new TabPane(lib1, other, lib2);
TabObservableList<Tab> base = (TabObservableList) tabPane.getTabs();

FilteredList<Tab> filtered = new FilteredList<>(base, tab -> tab.getText().startsWith("lib"));

base.reorder(lib1, other);

// following outputs "true", but should be "false"
System.out.println(other == filtered.getFirst());


EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
filtered is list of lib1, lib2
ACTUAL -
filtered is list of other, lib2

---------- BEGIN SOURCE ----------
package org.jabref.gui.javafx;

import java.util.List;

import javafx.collections.transformation.FilteredList;
import javafx.scene.control.Tab;
import javafx.scene.control.TabPane;

import com.sun.javafx.scene.control.TabObservableList;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.testfx.framework.junit5.ApplicationExtension;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals;

@ExtendWith(ApplicationExtension.class)
public class TabObservableListFilteredTest {

    @Test
    public void filteredListDetectsPermutation() {
        Tab lib1 = new Tab("lib1");
        Tab lib2 = new Tab("lib2");
        Tab other = new Tab("other");

        TabPane tabPane = new TabPane(lib1, other, lib2);
        TabObservableList<Tab> base = (TabObservableList) tabPane.getTabs();

        FilteredList<Tab> filtered = new FilteredList<>(base, tab -> tab.getText().startsWith("lib"));

        assertEquals(List.of(lib1, lib2), filtered);

        base.reorder(lib1, other);

        assertNotEquals(other, filtered.getFirst()); // This should not fail

        assertEquals(List.of(lib2, lib1), filtered);
    }
}

---------- END SOURCE ----------


Comments
ILW = MLM = P4 I = TabObservableList reorder(x, y) changes content of a filteredList build on tabPane.getTabs() L = can be reproduced as above W = no workaround
09-06-2025

The issue is reproducible. Tested on Windows 11 x64 machine. Run the attached reproducer > mvn test .... [ERROR] Failures: [ERROR] TabObservableListFilteredTest.filteredListDetectsPermutation:33 expected: not equal but was: <javafx.scene.control.Tab@5b799640> ....
09-06-2025