stevenzwu commented on code in PR #6746:
URL: https://github.com/apache/iceberg/pull/6746#discussion_r1096946728


##########
aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java:
##########
@@ -1314,55 +1281,27 @@ private <T extends SdkClientBuilder> void 
configureEndpoint(T builder, String en
     }
   }
 
-  @VisibleForTesting
-  <T extends UrlConnectionHttpClient.Builder> void 
configureUrlConnectionHttpClientBuilder(
-      T builder) {
-    if (httpClientUrlConnectionConnectionTimeoutMs != null) {
-      
builder.connectionTimeout(Duration.ofMillis(httpClientUrlConnectionConnectionTimeoutMs));
-    }
-
-    if (httpClientUrlConnectionSocketTimeoutMs != null) {
-      
builder.socketTimeout(Duration.ofMillis(httpClientUrlConnectionSocketTimeoutMs));
-    }
-  }
-
-  @VisibleForTesting
-  <T extends ApacheHttpClient.Builder> void configureApacheHttpClientBuilder(T 
builder) {
-    if (httpClientApacheConnectionTimeoutMs != null) {
-      
builder.connectionTimeout(Duration.ofMillis(httpClientApacheConnectionTimeoutMs));
-    }
-
-    if (httpClientApacheSocketTimeoutMs != null) {
-      
builder.socketTimeout(Duration.ofMillis(httpClientApacheSocketTimeoutMs));
-    }
-
-    if (httpClientApacheConnectionAcquisitionTimeoutMs != null) {
-      builder.connectionAcquisitionTimeout(
-          Duration.ofMillis(httpClientApacheConnectionAcquisitionTimeoutMs));
-    }
-
-    if (httpClientApacheConnectionMaxIdleTimeMs != null) {
-      
builder.connectionMaxIdleTime(Duration.ofMillis(httpClientApacheConnectionMaxIdleTimeMs));
-    }
-
-    if (httpClientApacheConnectionTimeToLiveMs != null) {
-      
builder.connectionTimeToLive(Duration.ofMillis(httpClientApacheConnectionTimeToLiveMs));
-    }
-
-    if (httpClientApacheExpectContinueEnabled != null) {
-      builder.expectContinueEnabled(httpClientApacheExpectContinueEnabled);
-    }
-
-    if (httpClientApacheMaxConnections != null) {
-      builder.maxConnections(httpClientApacheMaxConnections);
-    }
-
-    if (httpClientApacheTcpKeepAliveEnabled != null) {
-      builder.tcpKeepAlive(httpClientApacheTcpKeepAliveEnabled);
-    }
-
-    if (httpClientApacheUseIdleConnectionReaperEnabled != null) {
-      
builder.useIdleConnectionReaper(httpClientApacheUseIdleConnectionReaperEnabled);
+  private HttpClientConfigurations loadHttpClientConfigurations(
+      String impl, Map<String, String> httpClientProperties) {
+    DynConstructors.Ctor<HttpClientConfigurations> ctor;
+    try {
+      ctor =
+          
DynConstructors.builder(HttpClientConfigurations.class).hiddenImpl(impl).buildChecked();
+      HttpClientConfigurations httpClientConfigurations = ctor.newInstance();
+      httpClientConfigurations.initialize(httpClientProperties);
+      return httpClientConfigurations;
+    } catch (NoSuchMethodException e) {
+      throw new IllegalArgumentException(
+          String.format(
+              "Cannot initialize HttpClientConfigurations Implementation %s: 
%s",
+              impl, e.getMessage()),

Review Comment:
   no need to add `e.getMessage` since `e` is already included in the cause.



##########
aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java:
##########
@@ -1314,55 +1281,27 @@ private <T extends SdkClientBuilder> void 
configureEndpoint(T builder, String en
     }
   }
 
-  @VisibleForTesting
-  <T extends UrlConnectionHttpClient.Builder> void 
configureUrlConnectionHttpClientBuilder(
-      T builder) {
-    if (httpClientUrlConnectionConnectionTimeoutMs != null) {
-      
builder.connectionTimeout(Duration.ofMillis(httpClientUrlConnectionConnectionTimeoutMs));
-    }
-
-    if (httpClientUrlConnectionSocketTimeoutMs != null) {
-      
builder.socketTimeout(Duration.ofMillis(httpClientUrlConnectionSocketTimeoutMs));
-    }
-  }
-
-  @VisibleForTesting
-  <T extends ApacheHttpClient.Builder> void configureApacheHttpClientBuilder(T 
builder) {
-    if (httpClientApacheConnectionTimeoutMs != null) {
-      
builder.connectionTimeout(Duration.ofMillis(httpClientApacheConnectionTimeoutMs));
-    }
-
-    if (httpClientApacheSocketTimeoutMs != null) {
-      
builder.socketTimeout(Duration.ofMillis(httpClientApacheSocketTimeoutMs));
-    }
-
-    if (httpClientApacheConnectionAcquisitionTimeoutMs != null) {
-      builder.connectionAcquisitionTimeout(
-          Duration.ofMillis(httpClientApacheConnectionAcquisitionTimeoutMs));
-    }
-
-    if (httpClientApacheConnectionMaxIdleTimeMs != null) {
-      
builder.connectionMaxIdleTime(Duration.ofMillis(httpClientApacheConnectionMaxIdleTimeMs));
-    }
-
-    if (httpClientApacheConnectionTimeToLiveMs != null) {
-      
builder.connectionTimeToLive(Duration.ofMillis(httpClientApacheConnectionTimeToLiveMs));
-    }
-
-    if (httpClientApacheExpectContinueEnabled != null) {
-      builder.expectContinueEnabled(httpClientApacheExpectContinueEnabled);
-    }
-
-    if (httpClientApacheMaxConnections != null) {
-      builder.maxConnections(httpClientApacheMaxConnections);
-    }
-
-    if (httpClientApacheTcpKeepAliveEnabled != null) {
-      builder.tcpKeepAlive(httpClientApacheTcpKeepAliveEnabled);
-    }
-
-    if (httpClientApacheUseIdleConnectionReaperEnabled != null) {
-      
builder.useIdleConnectionReaper(httpClientApacheUseIdleConnectionReaperEnabled);
+  private HttpClientConfigurations loadHttpClientConfigurations(
+      String impl, Map<String, String> httpClientProperties) {
+    DynConstructors.Ctor<HttpClientConfigurations> ctor;
+    try {
+      ctor =
+          
DynConstructors.builder(HttpClientConfigurations.class).hiddenImpl(impl).buildChecked();
+      HttpClientConfigurations httpClientConfigurations = ctor.newInstance();
+      httpClientConfigurations.initialize(httpClientProperties);
+      return httpClientConfigurations;
+    } catch (NoSuchMethodException e) {
+      throw new IllegalArgumentException(
+          String.format(
+              "Cannot initialize HttpClientConfigurations Implementation %s: 
%s",
+              impl, e.getMessage()),
+          e);
+    } catch (ClassCastException e) {
+      throw new IllegalArgumentException(
+          String.format(
+              "Cannot initialize HttpClientConfigurations, %s does not 
implement HttpClientConfigurations: %s",
+              impl, e.getMessage()),

Review Comment:
   no need to add `e.getMessage` since `e` is already included in the cause.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to