Skip to content

fix: Jump to Value Source on a value of an earlier stop says so, instead of sending that stop's location reference - #2180

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/dap-jump-to-value-source-of-an-earlier-stop
Nov 24, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/dap-jump-to-value-source-of-an-earlier-stop

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #2177

What

A valueLocationReference has the lifetime of a variablesReference: it is valid only until the program resumes. An
Evaluate result stays in its dialog across a step. "Jump to Value Source" (#2172) on it then sent the reference of the
earlier stop to the debug adapter. The adapter answered with an error, or with the location of another value, and the
editor opened a wrong place.

Change

  • DAPJumpToValueSourceAction sends the locations request with DAPClient.sendInExecutionEpoch, with the
    execution epoch of the value's frame, as Set Value has sent its requests since feat: set the value of an Evaluate result with the DAP setExpression request #2150. On a value of an earlier stop,
    no request is sent, and the session reports "Cannot locate the source of the value of 'onClick': The program has run
    since this value was shown: show it again to jump to the source of its value."
  • DAPClient.locations writes its request on the calling thread, as LSP4J and the other requests of DAPClient
    do. Before, it wrote it from a pool thread, which would have left the check and the write of
    sendInExecutionEpoch no longer atomic against a resume. The action now calls it off the EDT. locations was added
    by feat: jump from a DAP variable to the source of its value, with the locations request #2172 and isn't released yet.
  • DAPClient.sendInExecutionEpoch gets an overload with the message of a refused request. The existing method keeps
    Set Value's message.

Tests

  • New DAPJumpToValueSourceSessionTest.testJumpToValueSourceOfAnEvaluateResultOfAnEarlierStopSendsNoRequest:
    evaluate an expression whose result has a valueLocationReference, have the debug adapter stop again, then run the
    action on the kept result. It expects no locations request, the message, and no editor. It fails without the
    change, because the stale reference is sent, and passes with it.
  • The other 8 tests of the class still jump, now through sendInExecutionEpoch.
  • The dap.* tests pass on IC 2024.2, 2025.3 and IU 2026.3: 431 each, with 0 failures or skipped.

Behaviour change

Before After
Jump to Value Source on a value of an earlier stop sends that stop's reference, and opens the location of another value, or reports the adapter's error It sends nothing, and says that the program has run since the value was shown

…ead of sending that stop's location reference

A 'valueLocationReference' has the lifetime of a 'variablesReference': it
is valid only until the program resumes. An Evaluate result stays in its
dialog across a step, and "Jump to Value Source" sent its reference to the
debug adapter at the next stop, which then answered an error, or the
location of another value.

The action now sends the 'locations' request with sendInExecutionEpoch,
as Set Value sends its requests since redhat-developer#2150, and says "The program has run
since this value was shown: show it again to jump to the source of its
value." DAPClient.locations writes its request on the calling thread, as
the other requests do, so that the check and the write are atomic against
a resume; the action calls it off the EDT. sendInExecutionEpoch gets an
overload with the message of a refused request.

Fixes redhat-developer#2177
@lagergren lagergren added this to the 0.30.2 milestone Nov 24, 2026
@lagergren lagergren added the bug Something isn't working label Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Jumping to a value’s source now detects when the program has resumed since the value was displayed. In that case, the source is not opened, and a message asks you to display the value again before retrying.

Jump to Value Source now checks the value’s execution epoch before sending a DAP locations request. If the epoch has ended, it reports a stale-value message instead of sending the request. DAPClient now sends locations on the calling thread.

Changes: Value-source epoch guard

Layer / File(s) Summary
DAP request and epoch API
src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPClient.java
locations sends the request on the calling thread. sendInExecutionEpoch now accepts a custom stale-epoch failure message.
Guard Jump to Value Source
src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPJumpToValueSourceAction.java, src/main/resources/messages/DAPBundle.properties, src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPJumpToValueSourceSessionTest.java
The action sends the location request through the value’s execution epoch. A stale reference produces a message and sends no locations request. The test checks this behavior after another stop.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix · Severity of issue fixed: Medium

Sequence Diagram(s)

sequenceDiagram
  participant DAPJumpToValueSourceAction
  participant DAPClient
  participant DAPServer
  participant Editor
  DAPJumpToValueSourceAction->>DAPClient: sendInExecutionEpoch with value execution epoch
  alt Epoch has ended
    DAPClient-->>DAPJumpToValueSourceAction: stale-reference failure
  else Epoch is current
    DAPClient->>DAPServer: locations request
    DAPServer-->>DAPJumpToValueSourceAction: location response
    DAPJumpToValueSourceAction->>Editor: open source
  end
Loading

Suggested reviewers: angelozerr, muescha

Merge Risk: Minimal · up to 3e251

Jump to Value Source now refuses to send a stale location reference after the program has resumed and shows an explanatory message. Current-stop values still jump. No concrete merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Jump to Value Source on a value from an earlier stop now reports staleness instead of sending that stop's valueLocationReference. It matches the linked issue #2177 and…
Description check Passed The description is directly related to the changeset. It explains the stale valueLocationReference problem, the switch to DAPClient.sendInExecutionEpoch with the frame epoch, the locations request now…
Linked Issues check Passed Issue #2177 is the only direct link. Its coding requirements are: (1) Jump to Value Source on a value of an earlier stop sends no locations request; (2) it reports why it cannot jump, with a message…
Out of Scope Changes check Passed Each changed area supports the objective of #2177:
- DAPJumpToValueSourceAction: the epoch-guarded locations call, the message, and the off-EDT scheduling. Verified at head.
- `DAPClient.locations…
Full details: Title check

Explanation

The title names the main change: Jump to Value Source on a value from an earlier stop now reports staleness instead of sending that stop's valueLocationReference. It matches the linked issue #2177 and the changeset (DAPJumpToValueSourceAction, DAPClient.sendInExecutionEpoch overload, DAPBundle message, and the new test). The title is long (114 characters) and uses a 'fix:' prefix, but it is specific and accurate.

Full details: Description check

Explanation

The description is directly related to the changeset. It explains the stale valueLocationReference problem, the switch to DAPClient.sendInExecutionEpoch with the frame epoch, the locations request now written on the calling thread, the new sendInExecutionEpoch overload, the new test, and the behaviour change table.

Full details: Linked Issues check

Explanation

Issue #2177 is the only direct link. Its coding requirements are: (1) Jump to Value Source on a value of an earlier stop sends no locations request; (2) it reports why it cannot jump, with a message like Set Value's; (3) a value of the current stop still jumps; (4) a test covers the earlier-stop case. The reviewed head meets each of these:

  • DAPJumpToValueSourceAction.jumpToValueSource (read at head) calls client.sendInExecutionEpoch(epoch, () -> client.locations(reference), DAPBundle.message("dap.variables.valueSource.stale")), where epoch is value.getStackFrame().getExecutionEpoch(). This matches the issue's suggested approach. A refused request fails asynchronously, so no locations request is written for an ended stop.
  • The refusal message is the new dap.variables.valueSource.stale key in DAPBundle.properties, per the PR summary.
  • The request runs in CompletableFuture.supplyAsync on the app executor, so it is off the EDT, as the issue expects of locations after the write-thread change.
  • Current-stop values keep the existing path, because the epoch matches and the request is sent.
  • The test testJumpToValueSourceOfAnEvaluateResultOfAnEarlierStopSendsNoRequest is described in the PR as checking no request, the message, and no editor. I did not run it.
    The optional update disabling is not required by the issue.
Full details: Out of Scope Changes check

Explanation

Each changed area supports the objective of #2177:

  • DAPJumpToValueSourceAction: the epoch-guarded locations call, the message, and the off-EDT scheduling. Verified at head.
  • DAPClient.locations: now writes on the calling thread. The PR explains that this keeps the epoch check and the write atomic, and the action calls it off the EDT. The PR also states that locations was added by #2172 and is not released, so no released callers are affected. The DAPClient summary describes only this request-thread change and the new sendInExecutionEpoch overload.
  • DAPClient.sendInExecutionEpoch overload: it takes the refusal message as a parameter. The existing method keeps Set Value's message, so Set Value behavior does not change.
  • DAPBundle.properties: one new message key used by the action.
  • DAPJumpToValueSourceSessionTest: the new test and a test-server change so that the stop can be emitted again. Both support the required test.
    No change is unrelated to the issue.
Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 136e98cf-a3ba-499f-9412-c286de97114c
Commits

Reviewing files that changed from the base of the PR and between 8098f41 and 3e25132.

Files selected for processing: 4

  • src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPClient.java
  • src/main/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPJumpToValueSourceAction.java
  • src/main/resources/messages/DAPBundle.properties
  • src/test/java/com/redhat/devtools/lsp4ij/dap/client/variables/DAPJumpToValueSourceSessionTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 54.09%. Comparing base (8098f41) to head (3e25132).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2180      +/-   ##
==========================================
- Coverage   54.13%   54.09%   -0.05%     
==========================================
  Files         831      831              
  Lines       35275    35278       +3     
  Branches     5527     7273    +1746     
==========================================
- Hits        19096    19083      -13     
- Misses      13361    13366       +5     
- Partials     2818     2829      +11     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit a860b93 into redhat-developer:main Nov 24, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DAP: Jump to Value Source on a value of an earlier stop sends that stop's location reference

1 participant