dongjoon-hyun commented on code in PR #51545:
URL: https://github.com/apache/spark/pull/51545#discussion_r2214622574


##########
common/utils/src/main/java/org/apache/spark/network/util/JavaUtils.java:
##########
@@ -110,7 +108,15 @@ public static void deleteRecursively(File file, 
FilenameFilter filter)
     // On Unix systems, use operating system command to run faster
     // If that does not work out, fallback to the Java IO way
     // We exclude Apple Silicon test environment due to the limited resource 
issues.
-    if (SystemUtils.IS_OS_UNIX && filter == null && 
!(SystemUtils.IS_OS_MAC_OSX &&
+    String osName = System.getProperty("os.name");
+    boolean isMac = osName.regionMatches(true, 0, "Mac OS X", 0, 8);
+    String[] prefixes = {
+        "AIX", "HP-UX", "Irix", "Linux", "Mac OS X", "Solaris", "SunOS", 
"FreeBSD",
+        "OpenBSD", "NetBSD"
+    };
+    boolean isUnix = Arrays.stream(prefixes)
+        .anyMatch(prefix -> osName.regionMatches(true, 0, prefix, 0, 
prefix.length()));
+    if (isUnix && filter == null && !(isMac &&

Review Comment:
   Since this is the only one in `main` code, I clean this up in this PR 
together.
   
   **BEFORE**
   ```
   $ git grep SystemUtils | grep -v test
   
common/utils/src/main/java/org/apache/spark/network/util/JavaUtils.java:import 
org.apache.commons.lang3.SystemUtils;
   common/utils/src/main/java/org/apache/spark/network/util/JavaUtils.java:    
if (SystemUtils.IS_OS_UNIX && filter == null && !(SystemUtils.IS_OS_MAC_OSX &&
   core/src/main/scala/org/apache/spark/util/Utils.scala:import 
org.apache.commons.lang3.SystemUtils
   core/src/main/scala/org/apache/spark/util/Utils.scala:  val isUnix = 
SystemUtils.IS_OS_UNIX
   core/src/main/scala/org/apache/spark/util/Utils.scala:  val isWindows = 
SystemUtils.IS_OS_WINDOWS
   core/src/main/scala/org/apache/spark/util/Utils.scala:  val isMac = 
SystemUtils.IS_OS_MAC_OSX
   core/src/main/scala/org/apache/spark/util/Utils.scala:  val 
isMacOnAppleSilicon = SystemUtils.IS_OS_MAC_OSX && 
SystemUtils.OS_ARCH.equals("aarch64")
   ```
   
   **AFTER**
   ```
   $ git grep SystemUtils | grep -v test
   
common/utils/src/main/scala/org/apache/spark/util/SparkSystemUtils.scala:private[spark]
 trait SparkSystemUtils {
   
common/utils/src/main/scala/org/apache/spark/util/SparkSystemUtils.scala:object 
SparkSystemUtils extends SparkSystemUtils
   core/src/main/scala/org/apache/spark/util/Utils.scala:  with 
SparkSystemUtils {
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to