Fix flaky MMenuItemTest by retaining processing add-on references#4132
Open
vogella wants to merge 1 commit into
Open
Fix flaky MMenuItemTest by retaining processing add-on references#4132vogella wants to merge 1 commit into
vogella wants to merge 1 commit into
Conversation
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.
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.