Skip to content

Commit

Permalink
Using configured executor service for client.
Browse files Browse the repository at this point in the history
Signed-off-by: Tomas Langer <[email protected]>
  • Loading branch information
tomas-langer authored and jansupol committed Aug 28, 2019
1 parent 66f5cfa commit 38c1957
Showing 1 changed file with 15 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -451,18 +451,12 @@ public Builder property(final String name, final Object value) {

@Override
public CompletionStageRxInvoker rx() {
ExecutorServiceProvider instance = this.requestContext.getInjectionManager()
.getInstance(ExecutorServiceProvider.class);

return new JerseyCompletionStageRxInvoker(this, instance.getExecutorService());
return new JerseyCompletionStageRxInvoker(this, executorService());
}

@Override
public <T extends RxInvoker> T rx(Class<T> clazz) {
ExecutorServiceProvider instance = this.requestContext.getInjectionManager()
.getInstance(ExecutorServiceProvider.class);

return createRxInvoker(clazz, instance.getExecutorService());
return createRxInvoker(clazz, executorService());
}

private <T extends RxInvoker> T rx(Class<T> clazz, ExecutorService executorService) {
Expand All @@ -473,6 +467,19 @@ private <T extends RxInvoker> T rx(Class<T> clazz, ExecutorService executorServi
return createRxInvoker(clazz, executorService);
}

// get executor service from explicit configuration; if not available, get executor service from provider
private ExecutorService executorService() {
final ExecutorService result = request().getClientConfig().getExecutorService();

if (result != null) {
return result;
}

return this.requestContext.getInjectionManager()
.getInstance(ExecutorServiceProvider.class)
.getExecutorService();
}

/**
* Create {@link RxInvoker} from provided {@code RxInvoker} subclass.
* <p>
Expand Down

0 comments on commit 38c1957

Please sign in to comment.