Skip to content

Fix VirtualThread support on multiple unmount/remount cycles #10931

Open
PerfectSlayer wants to merge 1 commit intomasterfrom
bbujon/virtual-threads
Open

Fix VirtualThread support on multiple unmount/remount cycles #10931
PerfectSlayer wants to merge 1 commit intomasterfrom
bbujon/virtual-threads

Conversation

@PerfectSlayer
Copy link
Contributor

What Does This Do

This PR supersedes #10887 to fix context tracking on multiple virtual thread unmount / remount cycles.

Motivation

Previously, only one mount was supported, leading to context break.

Additional Notes

This PR is a re-implementation and adds the following changes compared to the original PR report:

  • Updates the Javadoc to clarify the expected lifecycle and context related operations
  • Distinguishes afterTerminate / afterDone hooks
  • Uses typed ContextScope to reduce unnecessary type casts
  • Avoid unnecessary null checks for null-safe API calls
  • Does not test remount cycle from the tests dedicated to VirtualThread and its builder API but creates a dedicated test suite
  • Does not limit to test the missing behavior but tests other cases too like:
    • multiple unmount/remount cycles
    • implicit (tracing) context restored
    • multiple virtual threads unmount/remount cycles
    • sanity check without context
  • Tries to trigger unmount more reliably - no dedicated API for so we can expect the test to flake
  • Removes the logging correlation concern from the test cases to focus only on context tracking
  • Adds thread join timeout

Contributor Checklist

Jira ticket: [PROJ-IDENT]

Note: Once your PR is ready to merge, add it to the merge queue by commenting /merge. /merge -c cancels the queue request. /merge -f --reason "reason" skips all merge queue checks; please use this judiciously, as some checks do not run at the PR-level. For more information, see this doc.

@PerfectSlayer PerfectSlayer requested a review from a team as a code owner March 23, 2026 13:00
@PerfectSlayer PerfectSlayer requested review from dougqh and removed request for a team March 23, 2026 13:00
@PerfectSlayer PerfectSlayer added type: bug Bug report and fix comp: context propagation Trace context propagation inst: java Core Java language instrumentation labels Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp: context propagation Trace context propagation inst: java Core Java language instrumentation type: bug Bug report and fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant