This is an automated email from the ASF dual-hosted git repository.

ajfabbri pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new eec2248a577 HADOOP-19833. Add regression test for 
fs.s3a.classloader.isolation=false behavior. (#8303)
eec2248a577 is described below

commit eec2248a5777a5ca2a0437456a4e40f1803729d7
Author: Deepak Jain <[email protected]>
AuthorDate: Tue May 5 14:24:48 2026 -0700

    HADOOP-19833. Add regression test for fs.s3a.classloader.isolation=false 
behavior. (#8303)
    
    Adds coverage in ITestS3AFileSystemIsolatedClassloader for the 
isolation=false path by calling getInstanceFromReflection directly and 
verifying that a custom credentials provider can be instantiated when the 
Configuration or application classloader supplies the class.
    
    No production code changes are included in this branch.
---
 .../s3a/ITestS3AFileSystemIsolatedClassloader.java | 25 ++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git 
a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AFileSystemIsolatedClassloader.java
 
b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AFileSystemIsolatedClassloader.java
index 98e924d8a00..21e1db8610a 100644
--- 
a/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AFileSystemIsolatedClassloader.java
+++ 
b/hadoop-tools/hadoop-aws/src/test/java/org/apache/hadoop/fs/s3a/ITestS3AFileSystemIsolatedClassloader.java
@@ -205,4 +205,29 @@ public void notIsolatedClassloader() throws IOException {
               .isInstanceOf(CustomCredentialsProvider.class);
     });
   }
+
+  /**
+   * HADOOP-19833: When isolation=false, getInstanceFromReflection must use
+   * the context classloader (or conf's classloader) so that classes from the
+   * application classpath can be loaded. This test calls 
getInstanceFromReflection
+   * directly with isolation=false and verifies the custom class is 
instantiated.
+   */
+  @Test
+  public void testGetInstanceFromReflectionWithIsolationFalse() throws 
Exception {
+    Map<String, String> confToSet =
+        mapOf(Constants.AWS_S3_CLASSLOADER_ISOLATION, "false");
+    assertInNewFilesystem(confToSet, (fs) -> {
+      try {
+        Configuration conf = fs.getConf();
+        AwsCredentialsProvider provider = S3AUtils.getInstanceFromReflection(
+            customClassName, conf, null, AwsCredentialsProvider.class, 
"create",
+            Constants.AWS_CREDENTIALS_PROVIDER);
+        Assertions.assertThat(provider)
+            .describedAs("getInstanceFromReflection with isolation=false")
+            .isInstanceOf(CustomCredentialsProvider.class);
+      } catch (IOException e) {
+        throw new AssertionError("getInstanceFromReflection threw", e);
+      }
+    });
+  }
 }


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

Reply via email to