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

pan3793 pushed a commit to branch branch-4.0
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/branch-4.0 by this push:
     new a335a9e723c4 [SPARK-60608][4.0][ML][CONNECT][FOLLOWUP] Fix 
MLClassLoadingSuite to expect the wrapped exception on branch-4.0
a335a9e723c4 is described below

commit a335a9e723c469cb20ea9112ee23b0263afd234d
Author: raviston <[email protected]>
AuthorDate: Mon Nov 2 15:11:11 2026 +0800

    [SPARK-60608][4.0][ML][CONNECT][FOLLOWUP] Fix MLClassLoadingSuite to expect 
the wrapped exception on branch-4.0
    
    ### What changes were proposed in this pull request?
    
    This is a branch-4.0 follow-up to #59854 (SPARK-60608). It fixes 
`MLClassLoadingSuite."reject an RFormulaModel with a non-allowlisted nested 
stage"` so that it expects the `InvocationTargetException` thrown by 
`MLUtils.loadOperator` and asserts that its cause is the 
`MlUnsupportedException` raised by the allowlist check.
    
    ### Why are the changes needed?
    
    The test fails on branch-4.0:
    
    ```
    Expected exception org.apache.spark.sql.connect.ml.MlUnsupportedException 
to be thrown,
    but java.lang.reflect.InvocationTargetException was thrown
    ...
    Caused by: org.apache.spark.sql.connect.ml.MlUnsupportedException: 
[CONNECT_ML.UNSUPPORTED_EXCEPTION]
    ... The class org.apache.spark.sql.connect.ml.UnregisteredModel to be 
loaded is not in the allowlist.
    ```
    
    On master, `MLUtils.loadOperator` unwraps the `InvocationTargetException` 
thrown by the reflective `load` call (SPARK-51333). That change was reverted 
from branch-4.0, so on this branch the expected exception arrives wrapped. The 
allowlist itself works correctly. Only the test expectation is wrong for this 
branch.
    
    This breaks CI for every PR against branch-4.0, for example #59915.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No, test-only.
    
    ### How was this patch tested?
    
    `build/sbt 'connect/testOnly *MLClassLoadingSuite'`
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: Claude Code (Claude Opus 5.5)
    
    🤖 Generated with [Claude Code](https://claude.com/claude-code)
    
    Closes #59949 from Raviston6296/SPARK-60608-4.0-followup.
    
    Lead-authored-by: raviston <[email protected]>
    Co-authored-by: raviston.t <[email protected]>
    Signed-off-by: Cheng Pan <[email protected]>
---
 .../org/apache/spark/sql/connect/ml/MLClassLoadingSuite.scala      | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/sql/connect/server/src/test/scala/org/apache/spark/sql/connect/ml/MLClassLoadingSuite.scala
 
b/sql/connect/server/src/test/scala/org/apache/spark/sql/connect/ml/MLClassLoadingSuite.scala
index d51997bad213..c45f7053c68c 100644
--- 
a/sql/connect/server/src/test/scala/org/apache/spark/sql/connect/ml/MLClassLoadingSuite.scala
+++ 
b/sql/connect/server/src/test/scala/org/apache/spark/sql/connect/ml/MLClassLoadingSuite.scala
@@ -18,6 +18,7 @@
 package org.apache.spark.sql.connect.ml
 
 import java.io.File
+import java.lang.reflect.InvocationTargetException
 
 import org.apache.spark.connect.proto
 import org.apache.spark.ml.{Model, Transformer}
@@ -125,9 +126,11 @@ class MLClassLoadingSuite extends MLHelper {
 
   test("reject an RFormulaModel with a non-allowlisted nested stage") {
     withSavedModel(new UnregisteredModel("stageFixture")) { path =>
-      val error = intercept[MlUnsupportedException] {
+      // branch-4.0 does not unwrap InvocationTargetException in 
MLUtils.loadOperator.
+      val error = intercept[InvocationTargetException] {
         readModel(path)
-      }
+      }.getCause
+      assert(error.isInstanceOf[MlUnsupportedException])
       assert(error.getMessage.contains(classOf[UnregisteredModel].getName))
       assert(error.getMessage.contains("not in the allowlist"))
     }


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

Reply via email to