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

richox pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/auron.git


The following commit(s) were added to refs/heads/master by this push:
     new 021ce985 [AURON #1639] Avoid ByteBuddyAgent inject when class not 
found (#1640)
021ce985 is described below

commit 021ce98507c409c3624a27d993996bbcb755051f
Author: cxzl25 <[email protected]>
AuthorDate: Wed Dec 17 19:42:06 2025 +0800

    [AURON #1639] Avoid ByteBuddyAgent inject when class not found (#1640)
    
    <!--
    Thanks for sending a pull request! Please keep the following tips in
    mind:
    - Start the PR title with the related issue ID, e.g. '[AURON #XXXX]
    Short summary...'.
    - Make your PR title clear and descriptive, summarizing what this PR
    changes.
      - Provide a concise example to reproduce the issue, if possible.
      - Keep the PR description up to date with all changes.
    -->
    
    # Which issue does this PR close?
    
    <!--
    We generally require a GitHub issue to be filed for all bug fixes and
    enhancements and this helps us generate change logs for our releases.
    You can link an issue to this PR using the GitHub syntax. For example
    `Closes #123` indicates that this PR will close issue #123.
    -->
    
    Closes #1639
    
     # Rationale for this change
    <!--
    Why are you proposing this change? If this is already explained clearly
    in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand
    your changes and offer better suggestions for fixes.
    -->
    
    # What changes are included in this PR?
    <!--
    There is no need to duplicate the description in the issue here but it
    is sometimes worth providing a summary of the individual changes in this
    PR.
    -->
    
    # Are there any user-facing changes?
    <!--
    If there are user-facing changes then we may require documentation to be
    updated before approving the PR.
    -->
    
    <!--
    If there are any breaking changes to public APIs, please add the `api
    change` label.
    -->
    
    # How was this patch tested?
    <!--
    If tests were added, say they were added here. Please make sure to add
    some test cases that check the changes thoroughly including negative and
    positive cases if possible.
    If it was tested in a way different from regular unit tests, please
    clarify how you tested step by step, ideally copy and paste-able, so
    that other reviewers can test and check, and descendants can verify in
    the future.
    If tests were not added, please describe why they were not added and/or
    why it was difficult to add.
    -->
---
 .../org/apache/spark/sql/auron/ValidateSparkPlanInjector.java | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git 
a/spark-extension-shims-spark/src/main/java/org/apache/spark/sql/auron/ValidateSparkPlanInjector.java
 
b/spark-extension-shims-spark/src/main/java/org/apache/spark/sql/auron/ValidateSparkPlanInjector.java
index 6685b1d7..c827036d 100644
--- 
a/spark-extension-shims-spark/src/main/java/org/apache/spark/sql/auron/ValidateSparkPlanInjector.java
+++ 
b/spark-extension-shims-spark/src/main/java/org/apache/spark/sql/auron/ValidateSparkPlanInjector.java
@@ -31,6 +31,7 @@ import org.slf4j.LoggerFactory;
 public class ValidateSparkPlanInjector {
 
     private static final Logger logger = 
LoggerFactory.getLogger(ValidateSparkPlanInjector.class);
+    private static volatile boolean classNotFound = false;
     private static boolean injected = false;
 
     public static synchronized void inject() {
@@ -38,12 +39,19 @@ public class ValidateSparkPlanInjector {
             logger.warn("ValidateSparkPlan already injected, skipping.");
             return;
         }
+        if (classNotFound) {
+            return;
+        }
         try {
-            ByteBuddyAgent.install();
+            // First check if the class exists before installing the agent
             ClassLoader contextClassLoader = 
Thread.currentThread().getContextClassLoader();
             TypeDescription typeDescription = 
TypePool.Default.of(contextClassLoader)
                     
.describe("org.apache.spark.sql.execution.adaptive.ValidateSparkPlan$")
                     .resolve();
+
+            // Only install ByteBuddyAgent if the class exists
+            ByteBuddyAgent.install();
+
             new ByteBuddy()
                     .redefine(typeDescription, 
ClassFileLocator.ForClassLoader.of(contextClassLoader))
                     .method(named("apply"))
@@ -53,6 +61,7 @@ public class ValidateSparkPlanInjector {
             logger.info("Successfully injected ValidateSparkPlan.");
             injected = true;
         } catch (TypePool.Resolution.NoSuchTypeException e) {
+            classNotFound = true;
             logger.debug("No such type of ValidateSparkPlan", e);
         }
     }

Reply via email to