From a7491f0f511bd8d7fbf5def0c312074674da825a Mon Sep 17 00:00:00 2001 From: mstr2 <43553916+mstr2@users.noreply.github.com> Date: Tue, 14 Jan 2025 02:48:35 +0100 Subject: [PATCH 1/2] failing tests --- .../VetoableObservableListTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/javafx.base/src/test/java/test/javafx/collections/VetoableObservableListTest.java b/modules/javafx.base/src/test/java/test/javafx/collections/VetoableObservableListTest.java index a5026ff1443..1de34d2f925 100644 --- a/modules/javafx.base/src/test/java/test/javafx/collections/VetoableObservableListTest.java +++ b/modules/javafx.base/src/test/java/test/javafx/collections/VetoableObservableListTest.java @@ -233,12 +233,36 @@ public void testRemove_indexed() { public void testRemoveAll() { list.removeAll(Arrays.asList("bar", "eggs", "foobar")); assertSingleCall(new String[0], new int[] {1,2,3,4}); + + list.setAll("a", "b", "c", "d", "e", "f"); + calls.clear(); + list.removeAll(List.of("b", "c", "d")); + assertEquals(List.of("a", "e", "f"), list); + assertSingleCall(new String[0], new int[] {1, 4}); + + list.setAll("a", "b", "c", "d", "e", "f"); + calls.clear(); + list.removeAll(List.of("a", "b", "d", "e", "f")); + assertEquals(List.of("c"), list); + assertSingleCall(new String[0], new int[] {0, 2, 3, 6}); } @Test public void testRetainAll() { list.retainAll(Arrays.asList("foo", "barfoo", "ham")); assertSingleCall(new String[0], new int[] {1,2,3,4}); + + list.setAll("a", "b", "c", "d", "e", "f"); + calls.clear(); + list.retainAll(List.of("a", "f")); + assertEquals(List.of("a", "f"), list); + assertSingleCall(new String[0], new int[] {1, 5}); + + list.setAll("a", "b", "c", "d", "e", "f"); + calls.clear(); + list.retainAll(List.of("c")); + assertEquals(List.of("c"), list); + assertSingleCall(new String[0], new int[] {0, 2, 3, 6}); } @Test From f348fea9cd1f54b73e7f85ea2c94c5cc2ecdde47 Mon Sep 17 00:00:00 2001 From: mstr2 <43553916+mstr2@users.noreply.github.com> Date: Tue, 14 Jan 2025 02:48:44 +0100 Subject: [PATCH 2/2] fix --- .../com/sun/javafx/collections/VetoableListDecorator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/javafx.base/src/main/java/com/sun/javafx/collections/VetoableListDecorator.java b/modules/javafx.base/src/main/java/com/sun/javafx/collections/VetoableListDecorator.java index 2b73be7bfc3..1fd8b318851 100644 --- a/modules/javafx.base/src/main/java/com/sun/javafx/collections/VetoableListDecorator.java +++ b/modules/javafx.base/src/main/java/com/sun/javafx/collections/VetoableListDecorator.java @@ -134,8 +134,8 @@ private void removeFromList(List backingList, int offset, Collection col, toBeRemoved[pointer + 2] = offset + i + 1; pointer += 2; } else { - if (toBeRemoved[pointer - 1] == offset + i) { - toBeRemoved[pointer - 1] = offset + i + 1; + if (toBeRemoved[pointer] == offset + i) { + toBeRemoved[pointer] = offset + i + 1; } else { int[] tmp = new int[toBeRemoved.length + 2]; System.arraycopy(toBeRemoved, 0, tmp, 0, toBeRemoved.length);