Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make @RunOnVirtualThread capture and run in a duplicated context #34524

Merged

Conversation

cescoffier
Copy link
Member

@cescoffier cescoffier commented Jul 4, 2023

With that change, the virtual thread gets the duplicated context of the request, allowing the propagation.

With this change, the following code:

@RunOnVirtualThread
@GET
public String hello() {
    return "hello " + Thread.currentThread() + " / " + Vertx.currentContext() + " / " + VertxContext.isOnDuplicatedContext();
}

produces:

=> hello VirtualThread[#198]/runnable@ForkJoinPool-1-worker-2 / io.vertx.core.impl.DuplicatedContext@752a5bde / true

It means that the virtual thread has access to the request duplicated context (that includes request scope, tracing, local data written by a filter...)

@quarkus-bot quarkus-bot bot added the area/rest label Jul 4, 2023
@cescoffier cescoffier requested a review from geoand July 4, 2023 14:07
@quarkus-bot
Copy link

quarkus-bot bot commented Jul 4, 2023

✔️ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

@cescoffier cescoffier merged commit e153bcc into quarkusio:main Jul 5, 2023
@quarkus-bot quarkus-bot bot added this to the 3.3 - main milestone Jul 5, 2023
@cescoffier cescoffier deleted the runOnVirtualThread-duplicated-context branch July 5, 2023 06:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants