Skip to content

Commit acfcd37

Browse files
witgopdeyhim
authored andcommitted
Fix SPARK-1629: Spark should inline use of commons-lang `SystemUtils.IS_...
...OS_WINDOWS` Author: witgo <[email protected]> Closes apache#569 from witgo/SPARK-1629 and squashes the following commits: 31520eb [witgo] Merge branch 'master' of https://github.com/apache/spark into SPARK-1629 fcaafd7 [witgo] merge mastet 49e248e [witgo] Fix SPARK-1629: Spark should inline use of commons-lang `SystemUtils.IS_OS_WINDOWS`
1 parent 1467f1c commit acfcd37

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

core/src/main/scala/org/apache/spark/util/Utils.scala

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ import scala.reflect.ClassTag
3131
import scala.util.Try
3232

3333
import com.google.common.io.Files
34-
import org.apache.commons.lang.SystemUtils
3534
import com.google.common.util.concurrent.ThreadFactoryBuilder
3635
import org.apache.hadoop.fs.{FileSystem, FileUtil, Path}
3736
import org.json4s._
@@ -50,7 +49,7 @@ private[spark] object Utils extends Logging {
5049
val random = new Random()
5150

5251
def sparkBin(sparkHome: String, which: String): File = {
53-
val suffix = if (SystemUtils.IS_OS_WINDOWS) ".cmd" else ""
52+
val suffix = if (isWindows) ".cmd" else ""
5453
new File(sparkHome + File.separator + "bin", which + suffix)
5554
}
5655

@@ -614,7 +613,7 @@ private[spark] object Utils extends Logging {
614613
*/
615614
def isSymlink(file: File): Boolean = {
616615
if (file == null) throw new NullPointerException("File must not be null")
617-
if (SystemUtils.IS_OS_WINDOWS) return false
616+
if (isWindows) return false
618617
val fileInCanonicalDir = if (file.getParent() == null) {
619618
file
620619
} else {
@@ -1018,7 +1017,7 @@ private[spark] object Utils extends Logging {
10181017
throw new IOException("Destination must be relative")
10191018
}
10201019
var cmdSuffix = ""
1021-
val linkCmd = if (SystemUtils.IS_OS_WINDOWS) {
1020+
val linkCmd = if (isWindows) {
10221021
// refer to http://technet.microsoft.com/en-us/library/cc771254.aspx
10231022
cmdSuffix = " /s /e /k /h /y /i"
10241023
"cmd /c xcopy "
@@ -1062,6 +1061,12 @@ private[spark] object Utils extends Logging {
10621061
getHadoopFileSystem(new URI(path))
10631062
}
10641063

1064+
/**
1065+
* return true if this is Windows.
1066+
*/
1067+
def isWindows = Option(System.getProperty("os.name")).
1068+
map(_.startsWith("Windows")).getOrElse(false)
1069+
10651070
/**
10661071
* Indicates whether Spark is currently running unit tests.
10671072
*/

0 commit comments

Comments
 (0)