diff options
author | Claes Redestad <claes.redestad@gmail.com> | 2016-02-14 11:49:37 +0000 |
---|---|---|
committer | Sean Owen <sowen@cloudera.com> | 2016-02-14 11:49:37 +0000 |
commit | 22e9723d6208f2cd2dfa26487ea1c041cb9d7dcd (patch) | |
tree | b610c1175d9725f8b88208c0e79126a98d566bd7 /launcher/src/main/java | |
parent | 331293c30242dc43e54a25171ca51a1c9330ae44 (diff) | |
download | spark-22e9723d6208f2cd2dfa26487ea1c041cb9d7dcd.tar.gz spark-22e9723d6208f2cd2dfa26487ea1c041cb9d7dcd.tar.bz2 spark-22e9723d6208f2cd2dfa26487ea1c041cb9d7dcd.zip |
[SPARK-13278][CORE] Launcher fails to start with JDK 9 EA
See http://openjdk.java.net/jeps/223 for more information about the JDK 9 version string scheme.
Author: Claes Redestad <claes.redestad@gmail.com>
Closes #11160 from cl4es/master.
Diffstat (limited to 'launcher/src/main/java')
-rw-r--r-- | launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java b/launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java index d30c2ec5f8..e328c8a341 100644 --- a/launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java +++ b/launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java @@ -322,11 +322,9 @@ class CommandBuilderUtils { if (getJavaVendor() == JavaVendor.IBM) { return; } - String[] version = System.getProperty("java.version").split("\\."); - if (Integer.parseInt(version[0]) > 1 || Integer.parseInt(version[1]) > 7) { + if (javaMajorVersion(System.getProperty("java.version")) > 7) { return; } - for (String arg : cmd) { if (arg.startsWith("-XX:MaxPermSize=")) { return; @@ -336,4 +334,20 @@ class CommandBuilderUtils { cmd.add("-XX:MaxPermSize=256m"); } + /** + * Get the major version of the java version string supplied. This method + * accepts any JEP-223-compliant strings (9-ea, 9+100), as well as legacy + * version strings such as 1.7.0_79 + */ + static int javaMajorVersion(String javaVersion) { + String[] version = javaVersion.split("[+.\\-]+"); + int major = Integer.parseInt(version[0]); + // if major > 1, we're using the JEP-223 version string, e.g., 9-ea, 9+120 + // otherwise the second number is the major version + if (major > 1) { + return major; + } else { + return Integer.parseInt(version[1]); + } + } } |