Skip to content

Fix flaky MMenuItemTest by retaining processing add-on references#4132

Open
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:lv/fix-1737-mmenuitem-gc-race
Open

Fix flaky MMenuItemTest by retaining processing add-on references#4132
vogella wants to merge 1 commit into
eclipse-platform:masterfrom
vogella:lv/fix-1737-mmenuitem-gc-race

Conversation

@vogella

@vogella vogella commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

testElementHierarchyInContext_HandledItem failed intermittently because the HandlerProcessingAddon it created via ContextInjectionFactory.make was only weakly referenced through its dependency-injection event subscription. Under garbage-collection pressure the add-on could be collected before the handler was activated, so the command was not executable and the handler never ran. This change keeps strong references to the created add-ons, which makes handler activation deterministic, and removes the earlier Thread.sleep wait loops that never addressed the real cause. Verified by forcing garbage collection in a stress harness: the old code failed 150 of 150 runs while the fixed version passed 200 of 200.

Fixes #1737.

The handler in testElementHierarchyInContext_HandledItem was activated by a
HandlerProcessingAddon created via ContextInjectionFactory.make, whose
dependency-injection event subscription holds the add-on only weakly. Because
the test discarded the make() result, the add-on could be garbage collected
before the window context was set, leaving the handler inactive so the command
was not executable and the menu item selection never ran it. Hold strong
references to the created add-ons and remove the ineffective sleep loops that
never addressed this.
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

   855 files  ±0     855 suites  ±0   51m 54s ⏱️ - 1m 12s
 8 083 tests ±0   7 840 ✅ ±0  243 💤 ±0  0 ❌ ±0 
20 151 runs  ±0  19 497 ✅ ±0  654 💤 ±0  0 ❌ ±0 

Results for commit d0abdf9. ± Comparison against base commit 55ec079.

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.

Random failing MMenuItemTest.testElementHierarchyInContext_HandledItem

1 participant