Skip to content

Commit

Permalink
Merge pull request #10175 from playframework/mergify/bp/2.8.x/pr-10162
Browse files Browse the repository at this point in the history
Overload HttpExecution.fromThread with ExecutionContextExecutor param (bp #10162)
  • Loading branch information
mergify[bot] committed Apr 9, 2020
2 parents b0e6bac + 052a607 commit 92cde25
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
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

0 comments on commit 92cde25

Please sign in to comment.