You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/11/22 16:59:35 UTC

[GitHub] [iceberg] rdblue commented on a diff in pull request #6169: AWS,Core: Add S3 REST Signer client + REST Spec

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


##########
aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java:
##########
@@ -1119,6 +1139,54 @@ public <T extends S3ClientBuilder> void applyS3ServiceConfigurations(T builder)
                 .build());
   }
 
+  /**
+   * Configure a signer for an S3 client.
+   *
+   * <p>Sample usage:
+   *
+   * <pre>
+   *     S3Client.builder().applyMutation(awsProperties::applyS3SignerConfiguration)
+   * </pre>
+   */
+  public <T extends S3ClientBuilder> void applyS3SignerConfiguration(T builder) {
+    if (null != s3SignerImpl) {
+      builder.overrideConfiguration(
+          c -> c.putAdvancedOption(SdkAdvancedClientOption.SIGNER, loadS3SignerDynamically()));
+    }
+  }
+
+  @SuppressWarnings("checkstyle:NestedTryDepth")
+  private Signer loadS3SignerDynamically() {
+    // load the signer implementation dynamically
+    Object signer;
+    try {
+      signer =
+          DynMethods.builder("of")

Review Comment:
   This seems suspicious to me. We don't use a static `of(Map)` for any other dynamically loaded class.



##########
aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java:
##########
@@ -1119,6 +1139,54 @@ public <T extends S3ClientBuilder> void applyS3ServiceConfigurations(T builder)
                 .build());
   }
 
+  /**
+   * Configure a signer for an S3 client.
+   *
+   * <p>Sample usage:
+   *
+   * <pre>
+   *     S3Client.builder().applyMutation(awsProperties::applyS3SignerConfiguration)
+   * </pre>
+   */
+  public <T extends S3ClientBuilder> void applyS3SignerConfiguration(T builder) {
+    if (null != s3SignerImpl) {
+      builder.overrideConfiguration(
+          c -> c.putAdvancedOption(SdkAdvancedClientOption.SIGNER, loadS3SignerDynamically()));
+    }
+  }
+
+  @SuppressWarnings("checkstyle:NestedTryDepth")
+  private Signer loadS3SignerDynamically() {
+    // load the signer implementation dynamically
+    Object signer;
+    try {
+      signer =
+          DynMethods.builder("of")
+              .impl(s3SignerImpl, Map.class)
+              .buildChecked()
+              .invoke(null, allProperties);

Review Comment:
   Instead of passing `null`, this should use `buildStatic`.



-- 
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-unsubscribe@iceberg.apache.org

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


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