fix(java): prevent ClassPrepareEvent from resuming stopped threads#27
Merged
debugmcpdev merged 2 commits intodebugmcp:mainfrom Mar 28, 2026
Merged
Conversation
… event loop When an EventSet contains both a stopping event (breakpoint, step, exception) and a ClassPrepareEvent, the ClassPrepareEvent's `resume = true` overwrites the stopping event's `resume = false`. This causes the thread to be resumed before evaluate_expression can access it, resulting in "Thread has been resumed" errors. Track whether a stopping event was seen in the current EventSet and only allow ClassPrepareEvent to set resume=true if no stopping event occurred. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ondition Adds a test that verifies evaluate_expression works when a BreakpointEvent with suspendPolicy="thread" fires while a ClassPrepareRequest is active for a not-yet-loaded class. Before the fix, the ClassPrepareEvent could override the breakpoint's resume=false flag, causing "Thread has been resumed" errors. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
|
Thanks for this fix, @Finomosec! The root cause analysis was spot-on, and the Merged as-is — nice work. |
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.
Summary
ClassPrepareEventin the sameEventSetas aBreakpointEventwould overrideresume = falsewithresume = true, incorrectly resuming the stopped thread"Thread has been resumed"errors when callingevaluate_expressionafter a breakpoint hit, especially withsuspendPolicy="thread"stoppedflag that prevents non-stopping events (ClassPrepare) from overriding the suspension decision of stopping events (Breakpoint, Step, Exception)Root Cause
In
JdiDapServer.java's event loop, events in anEventSetare processed sequentially. ABreakpointEventsetsresume = false, but a subsequentClassPrepareEventin the same set overwrites it withresume = true. TheeventSet.resume()at the end then resumes the thread before any evaluation can occur.Test plan
mcp-server-smoke-java-event-race.test.ts) that:suspendPolicy="thread"in main classClassPrepareRequest)evaluate_expressionsucceeds at the breakpoint (would fail before fix)suspendPolicy="thread", verify evaluation works🤖 Generated with Claude Code