From 11436896e67d367c6423fe0635abf0b3476f4426 Mon Sep 17 00:00:00 2001 From: Steven Massaro Date: Tue, 19 Jul 2022 12:14:38 -0500 Subject: [PATCH] error when JAVA_HOME is set to invalid value (DAT-10545) (#3074) Throw an error and fail to start Liquibase if the JAVA_HOME environment variable is set and the path it points to does not exist. --- liquibase-dist/src/main/archive/liquibase | 5 +++++ liquibase-dist/src/main/archive/liquibase.bat | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/liquibase-dist/src/main/archive/liquibase b/liquibase-dist/src/main/archive/liquibase index b1e10e39021..088a19e86ec 100644 --- a/liquibase-dist/src/main/archive/liquibase +++ b/liquibase-dist/src/main/archive/liquibase @@ -30,6 +30,11 @@ if [ -z "${JAVA_HOME}" ]; then elif [ -d "${LIQUIBASE_HOME}/.install4j/jre.bundle/Contents/Home" ]; then JAVA_HOME="${LIQUIBASE_HOME}/.install4j/jre.bundle/Contents/Home" fi +else + if [ ! -x "$JAVA_HOME" ] ; then + echo "ERROR: The JAVA_HOME environment variable is not defined correctly, so Liquibase cannot be started. JAVA_HOME is set to \"$JAVA_HOME\" and it does not exist." >&2 + exit 1 + fi fi if [ -z "${JAVA_HOME}" ]; then diff --git a/liquibase-dist/src/main/archive/liquibase.bat b/liquibase-dist/src/main/archive/liquibase.bat index 4ad3e373c64..99b54cb3ac9 100644 --- a/liquibase-dist/src/main/archive/liquibase.bat +++ b/liquibase-dist/src/main/archive/liquibase.bat @@ -17,6 +17,11 @@ if exist "%LIQUIBASE_HOME%\jre" if "%JAVA_HOME%"=="" ( set JAVA_HOME=%LIQUIBASE_HOME%\jre ) +if NOT "%JAVA_HOME%" == "" if not exist "%JAVA_HOME%" ( + echo ERROR: The JAVA_HOME environment variable is not defined correctly, so Liquibase cannot be started. JAVA_HOME is set to "%JAVA_HOME%" and it does not exist. >&2 + exit /B 1 +) + rem special characters may be lost setlocal DISABLEDELAYEDEXPANSION