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

Overload HttpExecution.fromThread with ExecutionContextExecutor param #10162

Merged
merged 1 commit into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions core/play/src/main/java/play/libs/concurrent/HttpExecution.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,18 @@ public static ExecutionContextExecutor fromThread(ExecutionContext delegate) {
return HttpExecutionContext.fromThread(delegate);
}

/**
* An ExecutionContext that executes work on the given ExecutionContext. The current thread's
* context ClassLoader is captured when this method is called and preserved for all executed
* tasks.
*
* @param delegate the delegate execution context.
* @return the execution context wrapped in an {@link play.libs.concurrent.HttpExecutionContext}.
*/
public static ExecutionContextExecutor fromThread(ExecutionContextExecutor delegate) {
return HttpExecutionContext.fromThread(delegate);
}

/**
* An ExecutionContext that executes work on the given ExecutionContext. The current thread's
* context ClassLoader is captured when this method is called and preserved for all executed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public Application(MyExecutionContext myExecutionContext) {

public CompletionStage<Result> index() {
// Wrap an existing thread pool, using the context from the current thread
Executor myEc = HttpExecution.fromThread((Executor) myExecutionContext);
Executor myEc = HttpExecution.fromThread(myExecutionContext);
return supplyAsync(() -> intensiveComputation(), myEc)
.thenApplyAsync(i -> ok("Got result: " + i), myEc);
}
Expand Down