Skip to content

Commit

Permalink
Fix SPARK-1629: Spark should inline use of commons-lang `SystemUtils.…
Browse files Browse the repository at this point in the history
…IS_...

...OS_WINDOWS`

Author: witgo <[email protected]>

Closes #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`
(cherry picked from commit 55100da)

Signed-off-by: Patrick Wendell <[email protected]>
  • Loading branch information
witgo authored and pwendell committed Apr 30, 2014
1 parent 177361c commit 74bb88b
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions core/src/main/scala/org/apache/spark/util/Utils.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import scala.reflect.ClassTag
import scala.util.Try

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

def sparkBin(sparkHome: String, which: String): File = {
val suffix = if (SystemUtils.IS_OS_WINDOWS) ".cmd" else ""
val suffix = if (isWindows) ".cmd" else ""
new File(sparkHome + File.separator + "bin", which + suffix)
}

Expand Down Expand Up @@ -614,7 +613,7 @@ private[spark] object Utils extends Logging {
*/
def isSymlink(file: File): Boolean = {
if (file == null) throw new NullPointerException("File must not be null")
if (SystemUtils.IS_OS_WINDOWS) return false
if (isWindows) return false
val fileInCanonicalDir = if (file.getParent() == null) {
file
} else {
Expand Down Expand Up @@ -1018,7 +1017,7 @@ private[spark] object Utils extends Logging {
throw new IOException("Destination must be relative")
}
var cmdSuffix = ""
val linkCmd = if (SystemUtils.IS_OS_WINDOWS) {
val linkCmd = if (isWindows) {
// refer to http://technet.microsoft.com/en-us/library/cc771254.aspx
cmdSuffix = " /s /e /k /h /y /i"
"cmd /c xcopy "
Expand Down Expand Up @@ -1062,6 +1061,12 @@ private[spark] object Utils extends Logging {
getHadoopFileSystem(new URI(path))
}

/**
* return true if this is Windows.
*/
def isWindows = Option(System.getProperty("os.name")).
map(_.startsWith("Windows")).getOrElse(false)

/**
* Indicates whether Spark is currently running unit tests.
*/
Expand Down

0 comments on commit 74bb88b

Please sign in to comment.