diff --git a/core/src/main/java/org/apache/iceberg/rest/HTTPClient.java b/core/src/main/java/org/apache/iceberg/rest/HTTPClient.java index 4391d75ec710..4ff494d0cfda 100644 --- a/core/src/main/java/org/apache/iceberg/rest/HTTPClient.java +++ b/core/src/main/java/org/apache/iceberg/rest/HTTPClient.java @@ -82,6 +82,8 @@ public class HTTPClient implements RESTClient { static final int REST_MAX_CONNECTIONS_DEFAULT = 100; static final String REST_MAX_CONNECTIONS_PER_ROUTE = "rest.client.connections-per-route"; static final int REST_MAX_CONNECTIONS_PER_ROUTE_DEFAULT = 100; + private static final String REST_USE_SYSTEM_PROPERTIES = "rest.client.use-system-properties"; + private static final boolean REST_USE_SYSTEM_PROPERTIES_DEFAULT = true; @VisibleForTesting static final String REST_CONNECTION_TIMEOUT_MS = "rest.client.connection-timeout-ms"; @@ -130,9 +132,18 @@ private HTTPClient( clientBuilder.setProxy(proxy); } + if (shouldUseSystemProperties(properties)) { + clientBuilder.useSystemProperties(); + } + this.httpClient = clientBuilder.build(); } + private static boolean shouldUseSystemProperties(Map properties) { + return PropertyUtil.propertyAsBoolean( + properties, REST_USE_SYSTEM_PROPERTIES, REST_USE_SYSTEM_PROPERTIES_DEFAULT); + } + private static String extractResponseBodyAsString(CloseableHttpResponse response) { try { if (response.getEntity() == null) { @@ -465,9 +476,11 @@ static HttpClientConnectionManager configureConnectionManager(Map