HttpAsyncClientBuilder: Make IOReactor exception callback configurable

This commit is contained in:
Ryan Schmitt 2021-03-31 10:51:26 -07:00 committed by Ryan Schmitt
parent 3f09dbee5a
commit f597588198
1 changed files with 12 additions and 1 deletions

View File

@ -209,6 +209,7 @@ public class HttpAsyncClientBuilder {
private AsyncClientConnectionManager connManager; private AsyncClientConnectionManager connManager;
private boolean connManagerShared; private boolean connManagerShared;
private IOReactorConfig ioReactorConfig; private IOReactorConfig ioReactorConfig;
private Callback<Exception> ioReactorExceptionCallback;
private Http1Config h1Config; private Http1Config h1Config;
private H2Config h2Config; private H2Config h2Config;
private CharCodingConfig charCodingConfig; private CharCodingConfig charCodingConfig;
@ -316,6 +317,16 @@ public class HttpAsyncClientBuilder {
return this; return this;
} }
/**
* Sets the callback that will be invoked when the client's IOReactor encounters an uncaught exception.
*
* @since 5.1
*/
public final HttpAsyncClientBuilder setIoReactorExceptionCallback(final Callback<Exception> ioReactorExceptionCallback) {
this.ioReactorExceptionCallback = ioReactorExceptionCallback;
return this;
}
/** /**
* Sets {@link CharCodingConfig} configuration. * Sets {@link CharCodingConfig} configuration.
*/ */
@ -932,7 +943,7 @@ public class HttpAsyncClientBuilder {
ioReactorConfig != null ? ioReactorConfig : IOReactorConfig.DEFAULT, ioReactorConfig != null ? ioReactorConfig : IOReactorConfig.DEFAULT,
threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true), threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true),
LoggingIOSessionDecorator.INSTANCE, LoggingIOSessionDecorator.INSTANCE,
LoggingExceptionCallback.INSTANCE, ioReactorExceptionCallback != null ? ioReactorExceptionCallback : LoggingExceptionCallback.INSTANCE,
null, null,
new Callback<IOSession>() { new Callback<IOSession>() {