Skip to content

Commit 8220484

Browse files
committed
Better scala implementation for determining major java version
1 parent 68159d8 commit 8220484

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

core/src/test/scala/org/apache/spark/util/UtilsSuite.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -784,8 +784,10 @@ class UtilsSuite extends SparkFunSuite with ResetSystemProperties with Logging {
784784
signal(pid, "SIGKILL")
785785
}
786786

787-
val v: String = System.getProperty("java.version")
788-
if (v >= "1.8.0") {
787+
val versionParts = System.getProperty("java.version").split("[+.\\-]+", 3)
788+
var majorVersion = versionParts(0).toInt
789+
if (majorVersion == 1) majorVersion = versionParts(1).toInt
790+
if (majorVersion >= 8) {
789791
// Java8 added a way to forcibly terminate a process. We'll make sure that works by
790792
// creating a very misbehaving process. It ignores SIGTERM and has been SIGSTOPed. On
791793
// older versions of java, this will *not* terminate.

project/SparkBuild.scala

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,10 @@ object SparkBuild extends PomBuild {
167167
publishLocalBoth <<= Seq(publishLocal in MavenCompile, publishLocal).dependOn,
168168

169169
javacOptions in (Compile, doc) ++= {
170-
val version = System.getProperty("java.version")
171-
if (version >= "1.8.0") Seq("-Xdoclint:all", "-Xdoclint:-missing") else Seq.empty
170+
val versionParts = System.getProperty("java.version").split("[+.\\-]+", 3)
171+
var major = versionParts(0).toInt
172+
if (major == 1) major = versionParts(1).toInt
173+
if (major >= 8) Seq("-Xdoclint:all", "-Xdoclint:-missing") else Seq.empty
172174
},
173175

174176
javacJVMVersion := "1.7",

0 commit comments

Comments
 (0)