You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by rs...@apache.org on 2021/03/31 18:32:32 UTC

[httpcomponents-client] branch master updated: HttpAsyncClientBuilder: Make IOReactor exception callback configurable

This is an automated email from the ASF dual-hosted git repository.

rschmitt pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git


The following commit(s) were added to refs/heads/master by this push:
     new f597588  HttpAsyncClientBuilder: Make IOReactor exception callback configurable
f597588 is described below

commit f5975881983f63560816b84038822751b9bb28e2
Author: Ryan Schmitt <ry...@amazon.com>
AuthorDate: Wed Mar 31 10:51:26 2021 -0700

    HttpAsyncClientBuilder: Make IOReactor exception callback configurable
---
 .../hc/client5/http/impl/async/HttpAsyncClientBuilder.java  | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
index 212bc57..612f35d 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/HttpAsyncClientBuilder.java
@@ -209,6 +209,7 @@ public class HttpAsyncClientBuilder {
     private AsyncClientConnectionManager connManager;
     private boolean connManagerShared;
     private IOReactorConfig ioReactorConfig;
+    private Callback<Exception> ioReactorExceptionCallback;
     private Http1Config h1Config;
     private H2Config h2Config;
     private CharCodingConfig charCodingConfig;
@@ -317,6 +318,16 @@ public class HttpAsyncClientBuilder {
     }
 
     /**
+     * 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.
      */
     public final HttpAsyncClientBuilder setCharCodingConfig(final CharCodingConfig charCodingConfig) {
@@ -932,7 +943,7 @@ public class HttpAsyncClientBuilder {
                 ioReactorConfig != null ? ioReactorConfig : IOReactorConfig.DEFAULT,
                 threadFactory != null ? threadFactory : new DefaultThreadFactory("httpclient-dispatch", true),
                 LoggingIOSessionDecorator.INSTANCE,
-                LoggingExceptionCallback.INSTANCE,
+                ioReactorExceptionCallback != null ? ioReactorExceptionCallback : LoggingExceptionCallback.INSTANCE,
                 null,
                 new Callback<IOSession>() {