Skip to content

Commit

Permalink
error when JAVA_HOME is set to invalid value (DAT-10545) (#3074)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
StevenMassaro committed Jul 19, 2022
1 parent 83faa21 commit 1143689
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions liquibase-dist/src/main/archive/liquibase
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions liquibase-dist/src/main/archive/liquibase.bat
Expand Up @@ -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

Expand Down

0 comments on commit 1143689

Please sign in to comment.