Commit 20be442
Fix race condition in FilteredItemsSelectionDialog initial selection
The flaky ResourceInitialSelectionTest failures were caused by a race
condition in FilteredItemsSelectionDialog.refresh() where setSelection()
was called immediately after tableViewer.refresh(), before the table had
fully updated its items.
Root cause:
- FilteredItemsSelectionDialog.refresh() calls tableViewer.refresh() (line 874)
- This triggers async table updates, especially for virtual tables
- setSelection() was called immediately after (line 883), assuming refresh
was complete
- On slow systems, the selection would be applied to an incomplete table
and silently fail, resulting in empty selection: expected:<[...foo.txt]>
but was:<[]>
The issue manifested as flaky test failures:
- testMultiSelectionAndSomeInitialNonExistingSelectionWithInitialPattern
- testSingleSelectionAndOneInitialSelectionWithInitialPattern
- testMultiSelectionAndTwoInitialSelectionsWithInitialPattern
These tests would intermittently fail with "Two files should be selected
by default" or "One file should be selected by default" assertions.
Solution:
Wrapped both selection application paths in Display.asyncExec() to defer
selection until after the table refresh completes:
1. For preserving previous selection:
- Changed from: tableViewer.setSelection(new StructuredSelection(...))
- Changed to: Display.asyncExec(() -> tableViewer.setSelection(...))
2. For default first item selection:
- Changed from: table.setSelection(0)
- Changed to: Display.asyncExec(() -> table.setSelection(0))
Both paths now include disposal checks to prevent errors if the dialog
is closed before the async execution runs.
The test's existing waitForDialogRefresh() method processes these async
events through its processUIEvents() calls, ensuring selections are
applied before assertions run. Updated the comment to reflect the
asyncExec fix.
Verified with multiple consecutive test runs - all 13 tests pass
consistently.
Fixes: #294
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>1 parent 6d06b55 commit 20be442
File tree
2 files changed
+18
-7
lines changed- bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/dialogs
- tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs
2 files changed
+18
-7
lines changedLines changed: 16 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
879 | 879 | | |
880 | 880 | | |
881 | 881 | | |
882 | | - | |
883 | | - | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
884 | 892 | | |
885 | 893 | | |
886 | | - | |
887 | | - | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
888 | 900 | | |
889 | 901 | | |
890 | 902 | | |
| |||
Lines changed: 2 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
471 | 471 | | |
472 | 472 | | |
473 | 473 | | |
474 | | - | |
475 | | - | |
476 | | - | |
| 474 | + | |
| 475 | + | |
477 | 476 | | |
478 | 477 | | |
479 | 478 | | |
| |||
0 commit comments