From 55951e2acf2bec5e443fd3e718c63e1510cd567e Mon Sep 17 00:00:00 2001 From: iacsha <122627209+iacsha@users.noreply.github.com> Date: Fri, 6 Nov 2026 19:47:06 +0000 Subject: [PATCH 1/2] 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> --- server/basedir-includes/oieserver | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/server/basedir-includes/oieserver b/server/basedir-includes/oieserver index e8f7b63740..cf679fd05e 100755 --- a/server/basedir-includes/oieserver +++ b/server/basedir-includes/oieserver @@ -138,7 +138,11 @@ is_valid_java_version() { # Extract the major version number. This works for formats like "1.8.0" and "17.0.2". local major_version - major_version=$(echo "$version_output" | head -n 1 | cut -d '"' -f 2 | cut -d '.' -f 1) + # Select the line with the quoted version string rather than the first line, so a + # "Picked up JAVA_TOOL_OPTIONS:" banner (printed to stderr when JAVA_TOOL_OPTIONS or + # _JAVA_OPTIONS is set) is not mistaken for the version line. See + # OpenIntegrationEngine/engine#523. + major_version=$(echo "$version_output" | grep -E 'version "' | head -n 1 | cut -d '"' -f 2 | cut -d '.' -f 1) # Check if the extracted version is a number and meets the minimum requirement if [[ "$major_version" =~ ^[0-9]+$ ]] && [[ "$major_version" -ge "$MIN_JAVA_VERSION" ]]; then From 182f4bdc759166b8a96703df129c3838e25de558 Mon Sep 17 00:00:00 2001 From: iacsha <122627209+iacsha@users.noreply.github.com> Date: Fri, 6 Nov 2026 19:47:06 +0000 Subject: [PATCH 2/2] Simplify version parse to a single anchored bash regex (review feedback) Replace the grep/head/cut pipeline with a bash regex anchored on the quoted version string. Anchoring on version " keeps the Picked up JAVA_TOOL_OPTIONS banner (and any other number in the output) from being read as the version. Signed-off-by: iacsha <122627209+iacsha@users.noreply.github.com> --- server/basedir-includes/oieserver | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/server/basedir-includes/oieserver b/server/basedir-includes/oieserver index cf679fd05e..2855fbfe78 100755 --- a/server/basedir-includes/oieserver +++ b/server/basedir-includes/oieserver @@ -136,13 +136,13 @@ is_valid_java_version() { return 1 fi - # Extract the major version number. This works for formats like "1.8.0" and "17.0.2". - local major_version - # Select the line with the quoted version string rather than the first line, so a - # "Picked up JAVA_TOOL_OPTIONS:" banner (printed to stderr when JAVA_TOOL_OPTIONS or - # _JAVA_OPTIONS is set) is not mistaken for the version line. See - # OpenIntegrationEngine/engine#523. - major_version=$(echo "$version_output" | grep -E 'version "' | head -n 1 | cut -d '"' -f 2 | cut -d '.' -f 1) + # Extract the major version number by matching the quoted version string (e.g. + # openjdk version "17.0.2"). Matching 'version "' rather than scanning the whole + # output means a "Picked up JAVA_TOOL_OPTIONS:" banner - printed to stderr when + # JAVA_TOOL_OPTIONS or _JAVA_OPTIONS is set - or any other number in the output is + # not mistaken for the version. Works for both "1.8.0" and "17.0.2" formats. See #523. + local major_version="" + [[ "$version_output" =~ version\ \"([0-9]+) ]] && major_version="${BASH_REMATCH[1]}" # Check if the extracted version is a number and meets the minimum requirement if [[ "$major_version" =~ ^[0-9]+$ ]] && [[ "$major_version" -ge "$MIN_JAVA_VERSION" ]]; then