Skip to content

test: DAPRefusedResumeSessionTest records the pauses only once IntelliJ has told the listeners of the first stop - #2304

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:test/refused-resume-session-flake
Nov 27, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:test/refused-resume-session-flake

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

DAPRefusedResumeSessionTest.testAStopBeforeARefusedResumeAtABreakpointWhichDoesNotSuspendIsWhereTheSessionIsSuspended failed once on the IU 2026.3 CI job of #2302, whose changes are unrelated:

The frames where the session paused since it ran to the breakpoint: only at the newer stop expected:<[3]> but was:<[1, 3]>

Cause: a race in the test

IntelliJ marks a session suspended at a stop before it tells the session's listeners (sessionPaused), on the thread that suspended it, here a pool thread of the DAP client; in between it runs logPositionReached (checked in XDebugSessionImpl of 2024.2 and 2026.3). debug() returned as soon as the session showed the first stop, and recordPauses() then added its listener, which IntelliJ could still tell about that first stop:

  1. pool thread: positionReached for stop 1, the session shows frame 1;
  2. test thread: debug() sees it, recordPauses() adds its listener, Resume;
  3. pool thread: sessionPaused for stop 1 reaches the new listener, recorded as frame 1;
  4. then the stops that the test is about, and a pause at frame 3: [1, 3].

The product pauses once per stop and never at the stale stop.

Fix

The mock DAP server no longer stops by itself at configurationDone. debug() waits until the session exists and the server is configured (and has the breakpoint where there is one), adds a session listener, sends the first stop, and returns once IntelliJ has told that listener of the pause. A listener added from then on isn't told of it. All 14 tests start through debug().

Tests

  • Deterministic reproduction: a hold on IntelliJ's thread inside logPositionReached at the first stop, after the session shows the stop and before it tells the listeners. With the old test it fails every time with the CI message; with this one it passes. The hold isn't kept: it tests the test's own recording, and depends on an experimental extension point and a private method's name.
  • Headless: dap.stepping.* on 2024.2, 28 tests; DAPRefusedResumeSessionTest on IU 2026.3, 14 tests. No failure, error or skip.

Test only, no change for users.

…iJ has told the listeners of the first stop

testAStopBeforeARefusedResumeAtABreakpointWhichDoesNotSuspendIsWhereTheSessionIsSuspended failed once
on CI (Test (ubuntu-latest, 2026.3), IU 2026.3, on PR redhat-developer#2302) with "The frames where the session paused
since it ran to the breakpoint: only at the newer stop expected:<[3]> but was:<[1, 3]>". The 1 was
the first stop, which the test had seen before it started recording.

XDebugSessionImpl.positionReached shows the session suspended (paused, suspend context, current frame)
before it tells the listeners with sessionPaused, on the thread that suspended the session, here a
common-pool thread of the DAP client. debug() returned as soon as the session showed the first stop,
and recordPauses() then added its listener. When that thread was still between the two, in
logPositionReached, the new listener was told of the first stop too, at frame 1, before the test
resumed the program:

  pool: positionReached(stop 1) shows the session suspended at frame 1
  EDT:  debug() sees it, recordPauses() adds the listener, then Resume
  pool: sessionPaused() for stop 1, recorded as frame 1
  ...   breakpoint stop 2 (doesn't suspend), 'stopped' 3, refused 'continue': pause at frame 3

The product paused once per stop, as it should: it doesn't suspend the session at the stale stop.

The DAP server of the test now stops first when the test says, once it is configured. debug() adds a
session listener before that, and returns only once IntelliJ has told it of the first pause. A listener
added after that isn't told of it, as IntelliJ tells the listeners that it has when it starts telling them.

Shown with a hold of IntelliJ's thread in logPositionReached at the first stop, until the test had
started recording: the test failed every time with the CI message on 2024.2. With this change and the
same hold, released while the session showed the stop but hadn't told its listeners yet, it passes.
@lagergren lagergren added this to the 0.30.2 milestone Nov 27, 2026
@coderabbitai

coderabbitai Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Improved coverage of debugger session startup and pause handling. The test now verifies that the session is ready and suspended before continuing, making checks of resume behavior more reliable.

The test now waits for DAP configuration and session readiness before directing the server to send the initial stopped event. It registers a pause listener before that event and waits for the listener notification, a suspended session, and frame 1.

Changes: Initial DAP pause

Layer / File(s) Summary
Coordinate the initial pause
src/test/java/com/redhat/devtools/lsp4ij/dap/stepping/DAPRefusedResumeSessionTest.java
The debug helper waits for configuration and session readiness, registers a pause listener, then directs the server to send the initial stopped event. configurationDone now only marks the server configured.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Other

Merge Risk: Minimal · up to 22d22

This change only affects a test and has no effect on users. It makes the DAP stepping test start deterministically so that an intermittent failure is less likely. No merge-blocking risk was found.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: DAPRefusedResumeSessionTest now records pauses only after IntelliJ notifies listeners of the first stop. This matches the test-only fix that moves the first stop into …
Description check Passed The description explains the failing CI assertion, the race between IntelliJ marking the session suspended and notifying listeners, the fix in the mock DAP server and debug() method, and the tests run…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: DAPRefusedResumeSessionTest now records pauses only after IntelliJ notifies listeners of the first stop. This matches the test-only fix that moves the first stop into debug(), which registers the listener before sending the stop. The 'test:' prefix is a conventional commit type and the title is a single sentence, though at 112 characters it is somewhat long.

Full details: Description check

Explanation

The description explains the failing CI assertion, the race between IntelliJ marking the session suspended and notifying listeners, the fix in the mock DAP server and debug() method, and the tests run. It matches the raw summary's changes to DAPRefusedResumeSessionTest.

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: e5f10087-97f9-476d-b4b6-b5fcf07f9d3b
Commits

Reviewing files that changed from the base of the PR and between a900e49 and 22d2232.

Files selected for processing: 1

  • src/test/java/com/redhat/devtools/lsp4ij/dap/stepping/DAPRefusedResumeSessionTest.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 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.53%. Comparing base (a900e49) to head (22d2232).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2304      +/-   ##
==========================================
+ Coverage   58.51%   58.53%   +0.01%     
==========================================
  Files         847      847              
  Lines       36501    36501              
  Branches     7560     5733    -1827     
==========================================
+ Hits        21360    21365       +5     
- Misses      12136    12139       +3     
+ Partials     3005     2997       -8     

☔ 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 27, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

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

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 27, 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 1276e37 into redhat-developer:main Nov 27, 2026
12 checks passed
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.

1 participant