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

Using configured executor service for client. #4227

Merged
merged 1 commit into from
Aug 28, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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