Fix bug in detecting use of bundled JDK on macOS

This commit fixes a bug in detecting the use of the bundled JDK on
macOS. This bug arose because the path of Java home is different on
macOS.
This commit is contained in:
Jason Tedor 2019-03-31 19:42:22 -04:00
parent 567e8f8b63
commit cebe509460
No known key found for this signature in database
GPG Key ID: FA89F05560F16BC5
1 changed files with 6 additions and 1 deletions

View File

@ -19,6 +19,7 @@
package org.elasticsearch.monitor.jvm;
import org.apache.lucene.util.Constants;
import org.elasticsearch.Version;
import org.elasticsearch.common.Booleans;
import org.elasticsearch.common.SuppressForbidden;
@ -171,7 +172,11 @@ public class JvmInfo implements Writeable, ToXContentFragment {
*/
final String javaHome = System.getProperty("java.home");
final String userDir = System.getProperty("user.dir");
return PathUtils.get(javaHome).equals(PathUtils.get(userDir).resolve("jdk").toAbsolutePath());
if (Constants.MAC_OS_X) {
return PathUtils.get(javaHome).equals(PathUtils.get(userDir).resolve("jdk/Contents/Home").toAbsolutePath());
} else {
return PathUtils.get(javaHome).equals(PathUtils.get(userDir).resolve("jdk").toAbsolutePath());
}
}
public static JvmInfo jvmInfo() {