Use bundled JDK in Sys V init (#45593)

This commit addresses an issue when trying to using Elasticsearch on
systems with Sys V init and the bundled JDK was not being used. Instead,
we were still inadvertently trying to fallback on the path. This commit
removes that fallback as that is against our intentions for 7.x where we
only support the bundled JDK or an explicit JDK via JAVA_HOME.
This commit is contained in:
Jason Tedor 2019-08-15 16:14:57 -04:00
parent 6b72d42cb8
commit ec4182590f
No known key found for this signature in database
GPG Key ID: FA89F05560F16BC5
3 changed files with 37 additions and 18 deletions

View File

@ -81,16 +81,16 @@ if [ ! -x "$DAEMON" ]; then
fi
checkJava() {
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA=`which java`
fi
if [ ! -z "${JAVA_HOME}" ]; then
JAVA="${JAVA_HOME}"/bin/java
else
JAVA="${ES_HOME}"/jdk/bin/java
fi
if [ ! -x "$JAVA" ]; then
echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME"
exit 1
fi
if [ ! -x "$JAVA" ]; then
echo "could not find java in JAVA_HOME or bundled at ${JAVA}"
exit 1
fi
}
case "$1" in

View File

@ -68,16 +68,16 @@ if [ ! -x "$exec" ]; then
fi
checkJava() {
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVA="$JAVA_HOME/bin/java"
else
JAVA=`which java`
fi
if [ ! -z "${JAVA_HOME}" ]; then
JAVA="${JAVA_HOME}"/bin/java
else
JAVA="${ES_HOME}"/jdk/bin/java
fi
if [ ! -x "$JAVA" ]; then
echo "Could not find any executable java binary. Please install java in your PATH or set JAVA_HOME"
exit 1
fi
if [ ! -x "$JAVA" ]; then
echo "could not find java in JAVA_HOME or bundled at ${JAVA}"
exit 1
fi
}
start() {

View File

@ -136,6 +136,25 @@ public abstract class PackageTestCase extends PackagingTestCase {
assertRunsWithJavaHome();
}
public void test33RunsIfJavaNotOnPath() throws Exception {
assumeThat(distribution().hasJdk, is(true));
final Result readlink = sh.run("readlink /usr/bin/java");
boolean unlinked = false;
try {
sh.run("unlink /usr/bin/java");
unlinked = true;
startElasticsearch(sh);
runElasticsearchTests();
stopElasticsearch(sh);
} finally {
if (unlinked) {
sh.run("ln -sf " + readlink.stdout.trim() + " /usr/bin/java");
}
}
}
public void test42BundledJdkRemoved() throws Exception {
assumeThat(installation, is(notNullValue()));
assumeThat(distribution().hasJdk, is(true));