rdblue commented on code in PR #6951:
URL: https://github.com/apache/iceberg/pull/6951#discussion_r1125568296


##########
core/src/main/java/org/apache/iceberg/rest/HTTPClient.java:
##########
@@ -361,6 +386,60 @@ public void close() throws IOException {
     httpClient.close(CloseMode.GRACEFUL);
   }
 
+  public static HTTPClient buildFrom(Map<String, String> properties) {
+    Builder builder = HTTPClient.builder();
+
+    builder.uri(properties.get(CatalogProperties.URI));
+
+    if (PropertyUtil.propertyAsBoolean(properties, SIGV4_ENABLED, false)) {
+      HttpRequestInterceptor interceptor =
+          loadInterceptorDynamically(SIGV4_REQUEST_INTERCEPTOR_IMPL, 
properties);
+      builder.withRequestInterceptor(interceptor);
+    }
+
+    return builder.build();
+  }
+
+  @VisibleForTesting
+  static HttpRequestInterceptor loadInterceptorDynamically(
+      String impl, Map<String, String> properties) {
+    HttpRequestInterceptor instance;
+
+    DynConstructors.Ctor<HttpRequestInterceptor> ctor;
+    try {
+      ctor =
+          DynConstructors.builder(HttpRequestInterceptor.class)
+              .loader(HTTPClient.class.getClassLoader())
+              .impl(impl)
+              .buildChecked();
+    } catch (NoSuchMethodException e) {
+      throw new IllegalArgumentException(
+          String.format(
+              "Cannot initialize RequestInterceptor, missing no-arg 
constructor: %s", impl),
+          e);
+    }
+
+    try {
+      instance = ctor.newInstance();
+    } catch (ClassCastException e) {
+      throw new IllegalArgumentException(
+          String.format("Cannot initialize, %s does not implement 
RequestInterceptor", impl), e);
+    }
+
+    DynMethods.builder("initialize")
+        .hiddenImpl(impl, Map.class)
+        .orNoop()
+        .build(instance)
+        .invoke(properties);
+
+    return instance;
+  }
+
+  /**
+   * @return http client builder
+   * @deprecated use {@link HTTPClient#buildFrom(Map)}

Review Comment:
   This should include when this can be removed. For example, "will be removed 
in 1.3.0; use HTTPClient.buildFrom".



-- 
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: issues-unsubscr...@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org
For additional commands, e-mail: issues-h...@iceberg.apache.org

Reply via email to