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

yuqi1129 pushed a commit to branch branch-1.3
in repository https://gitbox.apache.org/repos/asf/gravitino.git


The following commit(s) were added to refs/heads/branch-1.3 by this push:
     new 212803c710 [Cherry-pick to branch-1.3] [#12014] fix(core): Don't wrap 
plain ClassNotFoundException in IsolatedClassLoader (#12015) (#12033)
212803c710 is described below

commit 212803c710ed5dbd9fcea5865511713db56a21f4
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Thu Jul 16 14:43:05 2026 +0800

    [Cherry-pick to branch-1.3] [#12014] fix(core): Don't wrap plain 
ClassNotFoundException in IsolatedClassLoader (#12015) (#12033)
    
    **Cherry-pick Information:**
    - Original commit: 4ff7aac2590b2285df4ac19ccb47e75ed6098089
    - Target branch: `branch-1.3`
    - Status: ✅ Clean cherry-pick (no conflicts)
    
    Co-authored-by: jarred0214 <[email protected]>
    Co-authored-by: jarred0214 <[email protected]>
---
 .../java/org/apache/gravitino/utils/IsolatedClassLoader.java |  7 ++++++-
 .../org/apache/gravitino/utils/TestIsolatedClassLoader.java  | 12 ++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git 
a/core/src/main/java/org/apache/gravitino/utils/IsolatedClassLoader.java 
b/core/src/main/java/org/apache/gravitino/utils/IsolatedClassLoader.java
index 18784e41c1..6c80a6caba 100644
--- a/core/src/main/java/org/apache/gravitino/utils/IsolatedClassLoader.java
+++ b/core/src/main/java/org/apache/gravitino/utils/IsolatedClassLoader.java
@@ -172,8 +172,13 @@ public class IsolatedClassLoader implements Closeable {
 
       try {
         return clazz == null ? doLoadClass(name, resolve) : clazz;
+      } catch (ClassNotFoundException e) {
+        // Probe-driven callers, such as Janino, use a plain 
ClassNotFoundException as a
+        // signal that the current candidate name missed and they should try 
the next one.
+        // Wrapping it with a cause changes that signal into a fatal loading 
failure.
+        throw e;
       } catch (Exception e) {
-        throw new ClassNotFoundException("Class not found " + name, e);
+        throw new ClassNotFoundException("Failed to load " + name, e);
       }
     }
 
diff --git 
a/core/src/test/java/org/apache/gravitino/utils/TestIsolatedClassLoader.java 
b/core/src/test/java/org/apache/gravitino/utils/TestIsolatedClassLoader.java
index c2145dad89..7dc55b1343 100644
--- a/core/src/test/java/org/apache/gravitino/utils/TestIsolatedClassLoader.java
+++ b/core/src/test/java/org/apache/gravitino/utils/TestIsolatedClassLoader.java
@@ -44,6 +44,18 @@ public class TestIsolatedClassLoader {
     return (boolean) isCatalogClassMethod.invoke(classLoader, name);
   }
 
+  @Test
+  public void testClassNotFoundExceptionDoesNotWrapProbeMiss() {
+    // Probe-driven callers such as Janino expect a plain 
ClassNotFoundException for misses
+    // so they can continue trying the next candidate name.
+    ClassNotFoundException exception =
+        Assertions.assertThrows(
+            ClassNotFoundException.class,
+            () -> classLoader.withClassLoader(cl -> 
cl.loadClass("UnknownProbeClass")));
+
+    Assertions.assertNull(exception.getCause());
+  }
+
   @Test
   public void testHivePackageRecognizedAsCatalogClass() throws Exception {
     // org.apache.gravitino.hive.* was moved from catalog.hive.* by HiveClient 
refactoring.

Reply via email to