Skip to content

Commit 7f58ae6

Browse files
committed
Split java.version on non-digit char
1 parent 2db719c commit 7f58ae6

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

common/unsafe/src/main/java/org/apache/spark/unsafe/Platform.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ public final class Platform {
8888
private static final Method CLEANER_CREATE_METHOD;
8989
static {
9090
// The implementation of Cleaner changed from JDK 8 to 9
91-
int majorVersion = Integer.parseInt(System.getProperty("java.version").split("\\.")[0]);
91+
// Split java.version on non-digit chars:
92+
int majorVersion = Integer.parseInt(System.getProperty("java.version").split("\\D+")[0]);
9293
String cleanerClassName;
9394
if (majorVersion < 9) {
9495
cleanerClassName = "sun.misc.Cleaner";

core/src/main/scala/org/apache/spark/storage/StorageUtils.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ private[spark] object StorageUtils extends Logging {
201201
// reflection. However sun.misc.Unsafe added a invokeCleaner() method in JDK 9+ and this is
202202
// still accessible with reflection.
203203
private val bufferCleaner: DirectBuffer => Unit =
204-
if (System.getProperty("java.version").split("\\.").head.toInt < 9) {
204+
// Split java.version on non-digit chars:
205+
if (System.getProperty("java.version").split("\\D+").head.toInt < 9) {
205206
// scalastyle:off classforname
206207
val cleanerMethod = Class.forName("sun.misc.Cleaner").getMethod("clean")
207208
// scalastyle:on classforname

0 commit comments

Comments
 (0)