dpaani commented on code in PR #7066:
URL: https://github.com/apache/iceberg/pull/7066#discussion_r1140719347


##########
aws/src/main/java/org/apache/iceberg/aws/AwsProperties.java:
##########
@@ -1249,6 +1316,51 @@ private boolean s3KeyIdAccessKeyBothConfigured() {
     return (s3AccessKeyId == null) == (s3SecretAccessKey == null);
   }
 
+  private AwsCredentialsProvider credentialsProvider(String 
credentialsProviderClazz) {
+    try {
+      Class<?> providerClass =
+          DynClasses.builder()
+              .loader(this.getClass().getClassLoader())
+              .impl(credentialsProviderClazz)
+              .buildChecked();
+
+      ValidationException.check(
+          AwsCredentialsProvider.class.isAssignableFrom(providerClass),
+          "%s is not an instance of 
software.amazon.awssdk.auth.credentials.AwsCredentialsProvider, loaded by the 
classloader for %s",
+          providerClass,
+          this);
+
+      AwsCredentialsProvider provider;
+      try {
+        provider =
+            DynMethods.builder("create")
+                .hiddenImpl(credentialsProviderClazz, Map.class)

Review Comment:
   @RussellSpitzer DynMethods does not throw CNFE exception if a class does not 
exists. here is the code. 
   ```
       public Builder impl(String className, String methodName, Class<?>... 
argClasses) {
         // don't do any work if an implementation has been found
         if (method != null) {
           return this;
         }
   
         try {
           Class<?> targetClass = Class.forName(className, true, loader);
           impl(targetClass, methodName, argClasses);
         } catch (ClassNotFoundException e) {
           // not the right implementation
         }
         return this;
       }
   ```
   By calling DynClasses, I am able to validate CNFE and also adding Provider 
interface is implemented or not. 
   



-- 
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