Skip to content

fix: Ensure Java servers are invoked on the specified execution context#2082

Merged
johanandren merged 1 commit intomainfrom
wip-predictable-thread-pool
Oct 28, 2025
Merged

fix: Ensure Java servers are invoked on the specified execution context#2082
johanandren merged 1 commit intomainfrom
wip-predictable-thread-pool

Conversation

@johanandren
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This and SingleParameterSink is unrelated boyscouting

case "@method.grpcName":
response = @{method.unmarshal}(request.entity(), @method.deserializer.name, mat, reader)
.@{if(method.outputStreaming) { "thenApply" } else { "thenCompose" }}(e -> implementation.@{method.name}(e@{if(powerApis) { ", metadata" } else { "" }}))
.@{if(method.outputStreaming) { "thenApplyAsync" } else { "thenComposeAsync" }}(e -> implementation.@{method.name}(e@{if(powerApis) { ", metadata" } else { "" }}), mat.executionContext())
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to start off with one of the signatures that let's us enforce dispatcher, subsequent calls to thenApply will be on calling thread or this dispatcher.

That means calls will always lead to scheduling the invocation to the user service method impl, which means a bit more overhead, while before it could be invoked on the calling thread (which is safe here since already on the right dispatcher).

There seems to be no way around that, there is no way to say cs.useThisEc(ec) to make subsequent calls "inherit" it.

@johanandren johanandren merged commit 1959f1f into main Oct 28, 2025
16 checks passed
@johanandren johanandren deleted the wip-predictable-thread-pool branch October 28, 2025 08:21
@johanandren johanandren added this to the 2.5.8 milestone Oct 29, 2025
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.

2 participants