[Fix #1408] Do not rely on ServiceLoader instance creation#1409
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors callable task construction to avoid shared mutable state in ServiceLoader-provided CallableTaskBuilder instances, addressing flaky behavior when multiple call tasks use the same builder type.
Changes:
- Replaces the
init()+build()builder lifecycle withinit()returning aCallableTaskFactory. - Updates core, HTTP, OpenAPI, gRPC, and experimental Java function builders to capture per-task state in returned factories.
- Materializes callable task builders from
ServiceLoaderonce and improves the unsupported-task error message.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
impl/core/src/main/java/io/serverlessworkflow/impl/executors/CallableTaskFactory.java |
Adds factory interface for producing callable tasks. |
impl/core/src/main/java/io/serverlessworkflow/impl/executors/CallableTaskBuilder.java |
Changes builder SPI to return a factory from init. |
impl/core/src/main/java/io/serverlessworkflow/impl/executors/CallTaskExecutor.java |
Uses the returned factory to create callable tasks. |
impl/core/src/main/java/io/serverlessworkflow/impl/executors/DefaultTaskExecutorFactory.java |
Eagerly materializes ServiceLoader builders and updates lookup error text. |
impl/core/src/main/java/io/serverlessworkflow/impl/executors/CallFunctionExecutorBuilder.java |
Refactors call-function builder state into local factory captures. |
impl/http/src/main/java/io/serverlessworkflow/impl/executors/http/CallableTaskHttpExecutorBuilder.java |
Refactors HTTP call builder to return a per-task factory. |
impl/openapi/src/main/java/io/serverlessworkflow/impl/executors/openapi/OpenAPIExecutorBuilder.java |
Refactors OpenAPI call builder to return a per-task factory. |
impl/grpc/src/main/java/io/serverlessworkflow/impl/executors/grpc/GrpcExecutorBuilder.java |
Refactors gRPC call builder to return a per-task factory. |
experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaConsumerCallExecutorBuilder.java |
Refactors Java consumer call builder to return a factory. |
experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaContextFunctionCallExecutorBuilder.java |
Refactors Java context function builder to return a factory. |
experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaFilterFunctionCallExecutorBuilder.java |
Refactors Java filter function builder to return a factory. |
experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaFunctionCallExecutorBuilder.java |
Refactors Java function builder to return a factory. |
experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaLoopFunctionCallExecutorBuilder.java |
Refactors Java loop function builder to return a factory. |
experimental/lambda/src/main/java/io/serverlessworkflow/impl/executors/func/JavaLoopFunctionIndexCallExecutorBuilder.java |
Refactors Java indexed loop function builder to return a factory. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…reation Signed-off-by: fjtirado <ftirados@redhat.com>
ricardozanini
approved these changes
May 28, 2026
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.
Fix #1408