You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by fa...@apache.org on 2026/05/14 21:54:13 UTC

(hadoop) branch trunk updated: HADOOP-19890: s3a: fix isolated classloader test for jdk >=17 (#8491)

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 a3722991e71 HADOOP-19890: s3a: fix isolated classloader test for jdk >=17 (#8491)
a3722991e71 is described below

commit a3722991e7144635e217c49b77ee6db962a9d592
Author: Aaron Fabbri <fa...@apache.org>
AuthorDate: Thu May 14 14:54:07 2026 -0700

    HADOOP-19890: s3a: fix isolated classloader test for jdk >=17 (#8491)
    
    * HADOOP-19890: s3a: fix isolated classloader test for jdk >=17
---
 .../s3a/ITestS3AFileSystemIsolatedClassloader.java | 29 ++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)

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 21e1db8610a..ee5562b4952 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
@@ -26,6 +26,7 @@
 
 import org.assertj.core.api.Assertions;
 import org.junit.jupiter.api.Test;
+
 import software.amazon.awssdk.auth.credentials.AwsCredentials;
 import software.amazon.awssdk.auth.credentials.AwsCredentialsProvider;
 
@@ -34,8 +35,6 @@
 import org.apache.hadoop.fs.s3a.impl.InstantiationIOException;
 
 import static org.apache.hadoop.test.LambdaTestUtils.intercept;
-import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.spy;
 
 /**
  * Checks that classloader isolation for loading extension classes is applied
@@ -47,9 +46,9 @@ public class ITestS3AFileSystemIsolatedClassloader extends AbstractS3ATestBase {
 
   private static String customClassName = "custom.class.name";
 
-  private static class CustomCredentialsProvider implements AwsCredentialsProvider {
+  public static class CustomCredentialsProvider implements AwsCredentialsProvider {
 
-    CustomCredentialsProvider() {
+    public CustomCredentialsProvider() {
     }
 
     @Override
@@ -60,19 +59,23 @@ public AwsCredentials resolveCredentials() {
   }
 
   private static class CustomClassLoader extends ClassLoader {
-  }
 
-  private final ClassLoader customClassLoader = spy(new CustomClassLoader());
-  {
-    try {
-      doReturn(CustomCredentialsProvider.class)
-          .when(customClassLoader)
-          .loadClass(customClassName);
-    } catch (ClassNotFoundException ex) {
-      throw new RuntimeException(ex);
+    CustomClassLoader(ClassLoader parent) {
+      super(parent);
+    }
+
+    @Override
+    public Class<?> loadClass(String name) throws ClassNotFoundException {
+      if (customClassName.equals(name)) {
+        return CustomCredentialsProvider.class;
+      }
+      return super.loadClass(name);
     }
   }
 
+  private final ClassLoader customClassLoader =
+      new CustomClassLoader(ITestS3AFileSystemIsolatedClassloader.class.getClassLoader());
+
   private S3AFileSystem createNewTestFs(Configuration conf) throws IOException {
     S3AFileSystem fs = new S3AFileSystem();
     fs.initialize(getFileSystem().getUri(), conf);


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org