Skip to content

Commit

Permalink
Removed JAVA_HOME using only LS_JAVA_HOME (#13214)
Browse files Browse the repository at this point in the history
Removes the usage of JAVA_HOME completely which is not anymore used for JDK path resolution.

Updated all the Logstash launching scripts to use only LS_JAVA_HOME as environment variable to
determine the JDK to use to launch Logstash. JAVA_HOME is abandoned for this job.
  • Loading branch information
andsel authored Sep 15, 2021
1 parent 3ffdb99 commit d51afe5
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/bug.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ If the affected version of Logstash is 7.9 (or earlier), or if it is NOT using t

1. JVM version (`java -version`)
2. JVM installation source (e.g. from the Operating System's package manager, from source, etc).
3. Value of the `LS_JAVA_HOME`/`JAVA_HOME` environment variable if set.
3. Value of the `LS_JAVA_HOME` environment variable if set.

**OS version** (`uname -a` if on a Unix-like system):

Expand Down
14 changes: 1 addition & 13 deletions bin/logstash.lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
# The following env var will be used by this script if set:
# LS_GEM_HOME and LS_GEM_PATH to overwrite the path assigned to GEM_HOME and GEM_PATH
# LS_JAVA_OPTS to append extra options to the JVM options provided by logstash
# LS_JAVA_HOME to point to the java home (takes precedence over JAVA_HOME)
# (deprecated) JAVA_HOME to point to the java home
# LS_JAVA_HOME to point to the java home

unset CDPATH
# This unwieldy bit of scripting is to try to catch instances where Logstash
Expand Down Expand Up @@ -101,17 +100,6 @@ setup_java() {
else
echo "Invalid LS_JAVA_HOME, doesn't contain bin/java executable."
fi
elif [ -n "$JAVA_HOME" ]; then
echo "Using JAVA_HOME defined java: ${JAVA_HOME}"
if [ -x "$JAVA_HOME/bin/java" ]; then
JAVACMD="$JAVA_HOME/bin/java"
if [ -d "${LOGSTASH_HOME}/${BUNDLED_JDK_PART}" -a -x "${LOGSTASH_HOME}/${BUNDLED_JDK_PART}/bin/java" ]; then
echo "WARNING: Using JAVA_HOME while Logstash distribution comes with a bundled JDK."
fi
else
echo "Invalid JAVA_HOME, doesn't contain bin/java executable."
fi
echo "DEPRECATION: The use of JAVA_HOME is now deprecated and will be removed starting from 8.0. Please configure LS_JAVA_HOME instead."
elif [ -d "${LOGSTASH_HOME}/${BUNDLED_JDK_PART}" -a -x "${LOGSTASH_HOME}/${BUNDLED_JDK_PART}/bin/java" ]; then
echo "Using bundled JDK: ${LOGSTASH_HOME}/${BUNDLED_JDK_PART}"
JAVACMD="${LOGSTASH_HOME}/${BUNDLED_JDK_PART}/bin/java"
Expand Down
7 changes: 0 additions & 7 deletions bin/setup.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,6 @@ if defined LS_JAVA_HOME (
if exist "%LS_HOME%\jdk" (
echo WARNING: Using LS_JAVA_HOME while Logstash distribution comes with a bundled JDK.
)
) else if defined JAVA_HOME (
set JAVA="%JAVA_HOME%\bin\java.exe"
echo Using JAVA_HOME defined java: %JAVA_HOME%
if exist "%LS_HOME%\jdk" (
echo WARNING: Using JAVA_HOME while Logstash distribution comes with a bundled JDK.
)
echo DEPRECATION: The use of JAVA_HOME is now deprecated and will be removed starting from 8.0. Please configure LS_JAVA_HOME instead.
) else (
if exist "%LS_HOME%\jdk" (
set JAVA="%LS_HOME%\jdk\bin\java.exe"
Expand Down
5 changes: 1 addition & 4 deletions docs/static/jvm.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,11 @@ Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.1+13-LTS, mixed mode)

[float]
[[java-home]]
==== `LS_JAVA_HOME` and `JAVA_HOME`
==== `LS_JAVA_HOME`

{ls} uses the Java version set in `LS_JAVA_HOME`. The `LS_JAVA_HOME` environment
variable must be set for {ls} to operate correctly.

If {ls} doesn't find `LS_JAVA_HOME` it tries to fall back to `JAVA_HOME`.
The usage of `JAVA_HOME` is now considered deprecated in favor of `LS_JAVA_HOME`.

On some Linux systems, you may need to have the `LS_JAVA_HOME` environment
exported before installing {ls}, particularly if you installed Java from
a tarball.
Expand Down
1 change: 0 additions & 1 deletion qa/acceptance/spec/shared_examples/installed_with_jdk.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
before(:all) do
#unset to force it using bundled JDK to run LS
logstash.run_command("unset LS_JAVA_HOME")
logstash.run_command("unset JAVA_HOME")
end

before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion qa/docker/shared_examples/container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
console_out = exec_in_container(@container, 'logstash --version')
console_filtered = console_out.split("\n")
.delete_if do |line|
line =~ /Using LS_JAVA_HOME defined java|Using JAVA_HOME defined java|Using system java: /
line =~ /Using LS_JAVA_HOME defined java|Using system java: /
end.join
expect(console_filtered).to match /#{version}/
end
Expand Down
2 changes: 1 addition & 1 deletion qa/integration/specs/cli/prepare_offline_pack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
filters = @logstash_plugin.list(plugins_to_pack.first)
.stderr_and_stdout.split("\n")
.delete_if do |line|
line =~ /cext|├──|└──|logstash-integration|JAVA_OPT|fatal|^WARNING|^warning: ignoring JAVA_TOOL_OPTIONS|^OpenJDK 64-Bit Server VM warning|Option \w+ was deprecated|Using LS_JAVA_HOME defined java|Using JAVA_HOME defined java|Using system java: |\[\[: not found/
line =~ /cext|├──|└──|logstash-integration|JAVA_OPT|fatal|^WARNING|^warning: ignoring JAVA_TOOL_OPTIONS|^OpenJDK 64-Bit Server VM warning|Option \w+ was deprecated|Using LS_JAVA_HOME defined java|Using system java: |\[\[: not found/
end

expect(unpacked.plugins.collect(&:name)).to include(*filters)
Expand Down

0 comments on commit d51afe5

Please sign in to comment.