Skip to content

Conversation

@vogella
Copy link
Contributor

@vogella vogella commented Nov 17, 2025

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

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: eclipse-platform#294

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@vogella vogella marked this pull request as draft November 17, 2025 17:53
@github-actions
Copy link
Contributor

Test Results

 3 018 files  ±0   3 018 suites  ±0   2h 8m 25s ⏱️ - 8m 54s
 8 234 tests ±0   7 983 ✅  - 2  249 💤 ±0  2 ❌ +2 
23 622 runs  ±0  22 826 ✅  - 2  794 💤 ±0  2 ❌ +2 

For more details on these failures, see this check.

Results for commit 33748d2. ± Comparison against base commit a3fa065.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Some ResourceInitialSelectionTest tests fail intermittently

1 participant