Repository navigation
fix: loads of a DAP source given by reference which run at once ask the debug adapter for its text once - #2264
Merged
lagergren merged 1 commit intoNov 25, 2026
Conversation
…he debug adapter for its text once A source given by reference gets its text from the 'source' request, and each load of the text sent its own. Two loads of one source reference could run at once, and the debug adapter was asked twice or more: - DAPStackFrame.getSourcePosition() creates its position lazily, without a lock. The debug session publishes a stop (isSuspended(), the top frame) before it asks for the top frame's position on the DAP event thread, so the EDT, as the Frames view or the user showing the frame, and other threads ask for the same frame's position at once. Each caller that finds no position yet starts a load. - A frame loads its source's text unless its file holds it already, and the file holds it only once the first answer is stored. Two frames of one source, a later frame, Jump to Source or the Loaded Sources tab started a load of their own in the meantime. DAPClient.loadSource(sourceReference, store) now sends the 'source' request once for the loads of a source reference which run at once: - A load which starts before the one which asked has stored its answer gets that answer, and stores it itself, as before: in the file of its source reference, which keeps the text unless it differs. - The shared load ends once its answer is stored, or once the request or the store fails, before its future completes. A load after it asks again, so another text from the debug adapter still replaces the document's (redhat-developer#2204), and a failed or cancelled request leaves nothing behind. - The in-flight loads are kept by the client, whose source references they are, not by the file, which outlives the session. - DAPSourceReferencePosition loads through it. Tests, in DAPSameNameSourceReferencesSessionTest: - testFramesWhichAskForTheTextOfTheirSourceAtOnceAskTheDebugAdapterOnce: two frames of a source ask for its text while the debug adapter holds its answer. It is asked once; without the fix, twice. - testALoadOfASourceAsksAgainOnceTheRequestForItsTextFailed: the load after a failed request asks the debug adapter again and gets the text. - testAFrameWhichIsNotShownLoadsItsTextInItsOwnFile and testEachFrameShowsTheTextOfItsOwnSource no longer fail intermittently with a second request for the first source, as on a slow CI runner. Fixes redhat-developer#2263
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2264 +/- ##
==========================================
+ Coverage 55.82% 55.86% +0.03%
==========================================
Files 848 848
Lines 36265 36283 +18
Branches 7502 5686 -1816
==========================================
+ Hits 20245 20269 +24
+ Misses 13103 13096 -7
- Partials 2917 2918 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
Author
|
@coderabbitai review |
Action performed
|
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.
Fixes #2263
What
Each load of a source given by reference sent its own
sourcerequest. Two loads of one reference could run at once:DAPStackFrame.getSourcePosition()creates its position lazily, without a lock. The session publishes a stop before it asks for the top frame's position on the DAP event thread, so the EDT and other threads ask for the same frame at once.So the debug adapter got the same request twice or more, and
DAPSameNameSourceReferencesSessionTestfailed intermittently on a slow runner ([5, 5, 9]).Change
DAPClient.loadSource(sourceReference, store)sendssourceonce for the loads of a source reference which run at once. A load which starts before the one which asked has stored its answer gets that answer, and stores it itself, in its own file, as before.DAPSourceReferencePositionloads through it.sourcerequest when they asked at onceTests
testFramesWhichAskForTheTextOfTheirSourceAtOnceAskTheDebugAdapterOnce: red without the fix (3 requests instead of 2), green with it.testALoadOfASourceAsksAgainOnceTheRequestForItsTextFailed: guards against a stale in-flight entry.DAPSameNameSourceReferencesSessionTest×6 andcom.redhat.devtools.lsp4ij.dap.*(594 tests) are green.