Skip to content

Commit 42a8c3f

Browse files
committed
[MINOR] Avoid passing the PermGenSize option to IBM JVMs.
1 parent d70a076 commit 42a8c3f

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

launcher/src/main/java/org/apache/spark/launcher/AbstractCommandBuilder.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ List<String> buildJavaCommand(String extraClassPath) throws IOException {
121121
* set it.
122122
*/
123123
void addPermGenSizeOpt(List<String> cmd) {
124-
// Don't set MaxPermSize for Java 8 and later.
124+
// Don't set MaxPermSize for IBM Java, or Oracle Java 8 and later.
125+
if (getJavaVendor() == JavaVendor.IBM) {
126+
return;
127+
}
125128
String[] version = System.getProperty("java.version").split("\\.");
126129
if (Integer.parseInt(version[0]) > 1 || Integer.parseInt(version[1]) > 7) {
127130
return;

launcher/src/main/java/org/apache/spark/launcher/CommandBuilderUtils.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ class CommandBuilderUtils {
3232
static final String ENV_SPARK_HOME = "SPARK_HOME";
3333
static final String ENV_SPARK_ASSEMBLY = "_SPARK_ASSEMBLY";
3434

35+
/** The set of known JVM vendors. */
36+
static enum JavaVendor {
37+
Oracle, IBM, OpenJDK, Unknown
38+
};
39+
3540
/** Returns whether the given string is null or empty. */
3641
static boolean isEmpty(String s) {
3742
return s == null || s.isEmpty();
@@ -108,6 +113,23 @@ static boolean isWindows() {
108113
return os.startsWith("Windows");
109114
}
110115

116+
/** Returns an enum value indicating whose JVM is being used. */
117+
static JavaVendor getJavaVendor() {
118+
String vendorString = System.getProperty("java.vendor");
119+
if (vendorString.contains("Oracle")) {
120+
return JavaVendor.Oracle;
121+
} else {
122+
if (vendorString.contains("IBM")) {
123+
return JavaVendor.IBM;
124+
} else {
125+
if (vendorString.contains("OpenJDK")) {
126+
return JavaVendor.OpenJDK;
127+
}
128+
}
129+
}
130+
return JavaVendor.Unknown;
131+
}
132+
111133
/**
112134
* Updates the user environment, appending the given pathList to the existing value of the given
113135
* environment variable (or setting it if it hasn't yet been set).

0 commit comments

Comments
 (0)