fix(xtext.ui): iterate a snapshot of the matches when showing a running search - #1552
Merged
Merged
Conversation
…ng search FastReferenceSearchResultContentProvider.inputChanged iterated the live getMatchingReferences() list while the search job could still be appending to it, so re-showing a running search could throw a ConcurrentModificationException out of setInput and leave the page half-initialised. Iterate a copy and skip unpublished (null) slots. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
joaodinissf
added a commit
that referenced
this pull request
Sep 26, 2026
formal/README.md describes the method, target status, models and how to reproduce. formal/BUGS.md catalogues 51 findings (49 confirmed, 1 plausible, 1 refuted) plus 9 observations, all verified by three independent skeptics, with traces, test status, fix plans, a proposed fix-PR sequence and links to the fix PRs opened so far (#1550, #1551, #1552, #1553). REPORT.md is the chronological log of rounds 1-2. The patches are reference fixes used to show each disabled test turns green. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
rubenporras
approved these changes
Sep 28, 2026
joaodinissf
marked this pull request as ready for review
September 28, 2026 22:41
joaodinissf
added a commit
that referenced
this pull request
Sep 29, 2026
formal/README.md describes the method, target status, models and how to reproduce. formal/BUGS.md catalogues 51 findings (49 confirmed, 1 plausible, 1 refuted) plus 9 observations, all verified by three independent skeptics, with traces, test status, fix plans, a proposed fix-PR sequence and links to the fix PRs opened so far (#1550, #1551, #1552, #1553). REPORT.md is the chronological log of rounds 1-2. The patches are reference fixes used to show each disabled test turns green. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Sep 30, 2026
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.
Problem
FastReferenceSearchResultContentProvider.inputChangedrepopulates the view by iterating the liveReferenceSearchResult.getMatchingReferences()list. That is the internalArrayListthat the search job'saccept()appends to without a lock. If a search that is still running is shown, for example re-selected from the search history, the iteration can race the search thread. TheConcurrentModificationExceptionthen escapesviewer.setInput(...)and leaves the page half-initialised: the listener is registered, but the view is not populated.Who is affected: DDK's own languages use Xtext's default content provider, which has the same live iteration. This provider is used by products built on DDK that bind it.
Fix
Iterate a copy (
Lists.newArrayList(...)) and skipnullelements. The copy itself is unsynchronised, so it can observe a slot the search thread has reserved but not yet published.This removes the exception. It narrows the race rather than eliminating it: a reference can still be missed or shown twice at the boundary, and the related races in this provider are tracked separately.
Test
FastReferenceSearchResultContentProviderTestis registered inXtextUiTestSuite. A mockedIResourceDescriptionsappends a reference to the live list whileinputChangedis iterating it, which simulates the search thread deterministically. The test fails on master withConcurrentModificationExceptionand passes with the fix.Local run: full
mvn clean verifypasses apart from failures that also occur on master in this environment; checkstyle and PMD are clean.Found by the formal models of the find-references batching in #1549 (
formal/BUGS.md, REF-2): both the TLA+ and the Lean model reach it, and 3/3 independent reviewers upheld it.🤖 Generated with Claude Code