Skip to content

Commit 55951e2

Browse files
committed
Find Java correctly when JAVA_TOOL_OPTIONS is set (fixes #523)
is_valid_java_version parsed java -version with head -n 1, so the Picked up JAVA_TOOL_OPTIONS banner printed to stderr was read instead of the version line and every candidate Java was rejected. Select the line containing the quoted version string before cutting. Signed-off-by: iacsha <122627209+iacsha@users.noreply.github.com>
1 parent 0638c21 commit 55951e2

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎server/basedir-includes/oieserver‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,11 @@ is_valid_java_version() {
138138

139139
# Extract the major version number. This works for formats like "1.8.0" and "17.0.2".
140140
local major_version
141-
major_version=$(echo "$version_output" | head -n 1 | cut -d '"' -f 2 | cut -d '.' -f 1)
141+
# Select the line with the quoted version string rather than the first line, so a
142+
# "Picked up JAVA_TOOL_OPTIONS:" banner (printed to stderr when JAVA_TOOL_OPTIONS or
143+
# _JAVA_OPTIONS is set) is not mistaken for the version line. See
144+
# OpenIntegrationEngine/engine#523.
145+
major_version=$(echo "$version_output" | grep -E 'version "' | head -n 1 | cut -d '"' -f 2 | cut -d '.' -f 1)
142146

143147
# Check if the extracted version is a number and meets the minimum requirement
144148
if [[ "$major_version" =~ ^[0-9]+$ ]] && [[ "$major_version" -ge "$MIN_JAVA_VERSION" ]]; then

0 commit comments

Comments
 (0)