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

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


The following commit(s) were added to refs/heads/master by this push:
     new df3d8e4dbecd [SPARK-53256][CORE] Promote `check(Argument|State)` to 
`JavaUtils`
df3d8e4dbecd is described below

commit df3d8e4dbecdf79f68865ab13137993e676e96e6
Author: Dongjoon Hyun <dongj...@apache.org>
AuthorDate: Mon Aug 11 23:59:44 2025 -0700

    [SPARK-53256][CORE] Promote `check(Argument|State)` to `JavaUtils`
    
    ### What changes were proposed in this pull request?
    
    This PR aims to promote the following `checkArgument`, and `checkState` 
methods to `JavaUtils` by copying.
    
    
https://github.com/apache/spark/blob/1ae3d681983be9b7b46ec33282020e7d35b11903/launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java#L220-L232
    
    ### Why are the changes needed?
    
    - To reuse these Apache Spark utility methods widely in the whole Spark 
project.
    - Note that we need to clone because `launcher` module cannot have the 
other dependency and the existing methods are not `public`. I added the 
following style note to ensure them in sync in the future.
    
      > Keep this clone of CommandBuilderUtils.... synced with the original.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Manual review.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    No.
    
    Closes #51986 from dongjoon-hyun/SPARK-53256.
    
    Authored-by: Dongjoon Hyun <dongj...@apache.org>
    Signed-off-by: Dongjoon Hyun <dongj...@apache.org>
---
 .../org/apache/spark/network/util/JavaUtils.java     | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git 
a/common/utils-java/src/main/java/org/apache/spark/network/util/JavaUtils.java 
b/common/utils-java/src/main/java/org/apache/spark/network/util/JavaUtils.java
index 1ed05f2c18b1..cf500926fa3a 100644
--- 
a/common/utils-java/src/main/java/org/apache/spark/network/util/JavaUtils.java
+++ 
b/common/utils-java/src/main/java/org/apache/spark/network/util/JavaUtils.java
@@ -737,4 +737,24 @@ public class JavaUtils {
   public static boolean isUnix = Stream.of("AIX", "HP-UX", "Irix", "Linux", 
"Mac OS X", "Solaris",
     "SunOS", "FreeBSD", "OpenBSD", "NetBSD")
     .anyMatch(prefix -> osName.regionMatches(true, 0, prefix, 0, 
prefix.length()));
+
+  /**
+   * Throws IllegalArgumentException with the given message if the check is 
false.
+   * Keep this clone of CommandBuilderUtils.checkArgument synced with the 
original.
+   */
+  public static void checkArgument(boolean check, String msg, Object... args) {
+    if (!check) {
+      throw new IllegalArgumentException(String.format(msg, args));
+    }
+  }
+
+  /**
+   * Throws IllegalStateException with the given message if the check is false.
+   * Keep this clone of CommandBuilderUtils.checkState synced with the 
original.
+   */
+  public static void checkState(boolean check, String msg, Object... args) {
+    if (!check) {
+      throw new IllegalStateException(String.format(msg, args));
+    }
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to