SOLR-12141: Fix "bin/solr" shell scripts (Windows/Linux/Mac) to correctly detect major Java version and use numerical version comparison to enforce minimum requirements. Also remove obsolete "UseParNewGC" option. This allows to start Solr with Java 10 or later.

This commit is contained in:
Uwe Schindler 2018-03-27 22:49:23 +02:00
parent 08686038e1
commit ade2cf2e74
3 changed files with 23 additions and 17 deletions

View File

@ -373,6 +373,10 @@ Bug Fixes
* SOLR-12129: After the core is reloaded, term of the core will not be watched (Cao Manh Dat) * SOLR-12129: After the core is reloaded, term of the core will not be watched (Cao Manh Dat)
* SOLR-12141: Fix "bin/solr" shell scripts (Windows/Linux/Mac) to correctly detect major Java version
and use numerical version comparison to enforce minimum requirements. Also remove obsolete "UseParNewGC" option.
This allows to start Solr with Java 10 or later. (Uwe Schindler)
Optimizations Optimizations
---------------------- ----------------------

View File

@ -50,7 +50,7 @@ verbose=false
THIS_OS=`uname -s` THIS_OS=`uname -s`
# What version of Java is required to run this version of Solr. # What version of Java is required to run this version of Solr.
JAVA_VER_REQ="1.8" JAVA_VER_REQ="8"
stop_all=false stop_all=false
@ -138,10 +138,10 @@ if [[ $? -ne 0 ]] ; then
echo >&2 "${PATH}" echo >&2 "${PATH}"
exit 1 exit 1
else else
JAVA_VER_NUM=$(echo $JAVA_VER | head -1 | awk -F '"' '/version/ {print $2}') JAVA_VER_NUM=$(echo $JAVA_VER | head -1 | awk -F '"' '/version/ {print $2}' | sed -e's/^1\.//' | sed -e's/[._-].*$//')
if [[ "$JAVA_VER_NUM" < "$JAVA_VER_REQ" ]] ; then if [[ "$JAVA_VER_NUM" -lt "$JAVA_VER_REQ" ]] ; then
echo >&2 "Your current version of Java is too old to run this version of Solr" echo >&2 "Your current version of Java is too old to run this version of Solr."
echo >&2 "We found version $JAVA_VER_NUM, using command '${JAVA} -version', with response:" echo >&2 "We found major version $JAVA_VER_NUM, using command '${JAVA} -version', with response:"
echo >&2 "${JAVA_VER}" echo >&2 "${JAVA_VER}"
echo >&2 echo >&2
echo >&2 "Please install latest version of Java $JAVA_VER_REQ or set JAVA_HOME properly." echo >&2 "Please install latest version of Java $JAVA_VER_REQ or set JAVA_HOME properly."
@ -1828,7 +1828,7 @@ fi
# Establish default GC logging opts if no env var set (otherwise init to sensible default) # Establish default GC logging opts if no env var set (otherwise init to sensible default)
if [ -z ${GC_LOG_OPTS+x} ]; then if [ -z ${GC_LOG_OPTS+x} ]; then
if [[ "$JAVA_VER_NUM" < "9" ]] ; then if [[ "$JAVA_VER_NUM" -lt "9" ]] ; then
GC_LOG_OPTS=('-verbose:gc' '-XX:+PrintHeapAtGC' '-XX:+PrintGCDetails' \ GC_LOG_OPTS=('-verbose:gc' '-XX:+PrintHeapAtGC' '-XX:+PrintGCDetails' \
'-XX:+PrintGCDateStamps' '-XX:+PrintGCTimeStamps' '-XX:+PrintTenuringDistribution' \ '-XX:+PrintGCDateStamps' '-XX:+PrintGCTimeStamps' '-XX:+PrintTenuringDistribution' \
'-XX:+PrintGCApplicationStoppedTime') '-XX:+PrintGCApplicationStoppedTime')
@ -1841,7 +1841,7 @@ fi
# if verbose gc logging enabled, setup the location of the log file and rotation # if verbose gc logging enabled, setup the location of the log file and rotation
if [ "$GC_LOG_OPTS" != "" ]; then if [ "$GC_LOG_OPTS" != "" ]; then
if [[ "$JAVA_VER_NUM" < "9" ]] ; then if [[ "$JAVA_VER_NUM" -lt "9" ]] ; then
gc_log_flag="-Xloggc" gc_log_flag="-Xloggc"
if [ "$JAVA_VENDOR" == "IBM J9" ]; then if [ "$JAVA_VENDOR" == "IBM J9" ]; then
gc_log_flag="-Xverbosegclog" gc_log_flag="-Xverbosegclog"
@ -1953,7 +1953,6 @@ function launch_solr() {
'-XX:TargetSurvivorRatio=90' \ '-XX:TargetSurvivorRatio=90' \
'-XX:MaxTenuringThreshold=8' \ '-XX:MaxTenuringThreshold=8' \
'-XX:+UseConcMarkSweepGC' \ '-XX:+UseConcMarkSweepGC' \
'-XX:+UseParNewGC' \
'-XX:ConcGCThreads=4' '-XX:ParallelGCThreads=4' \ '-XX:ConcGCThreads=4' '-XX:ParallelGCThreads=4' \
'-XX:+CMSScavengeBeforeRemark' \ '-XX:+CMSScavengeBeforeRemark' \
'-XX:PretenureSizeThreshold=64m' \ '-XX:PretenureSizeThreshold=64m' \

View File

@ -178,7 +178,7 @@ IF NOT EXIST "%JAVA_HOME%\bin\java.exe" (
set "JAVA=%JAVA_HOME%\bin\java" set "JAVA=%JAVA_HOME%\bin\java"
CALL :resolve_java_info CALL :resolve_java_info
IF !JAVA_MAJOR_VERSION! LSS 8 ( IF !JAVA_MAJOR_VERSION! LSS 8 (
set "SCRIPT_ERROR=Java 1.8 or later is required to run Solr. Current Java version is: !JAVA_VERSION_INFO!" set "SCRIPT_ERROR=Java 1.8 or later is required to run Solr. Current Java version is: !JAVA_VERSION_INFO! (detected major: !JAVA_MAJOR_VERSION!)"
goto err goto err
) )
@ -1057,11 +1057,15 @@ IF ERRORLEVEL 1 (
set IS_JDK=true set IS_JDK=true
set "SERVEROPT=-server" set "SERVEROPT=-server"
) )
"%JAVA%" -d64 -version > nul 2>&1 if !JAVA_MAJOR_VERSION! LSS 9 (
IF ERRORLEVEL 1 ( "%JAVA%" -d64 -version > nul 2>&1
set "IS_64BIT=false" IF ERRORLEVEL 1 (
@echo WARNING: 32-bit Java detected. Not recommended for production. Point your JAVA_HOME to a 64-bit JDK set "IS_64BIT=false"
@echo. @echo WARNING: 32-bit Java detected. Not recommended for production. Point your JAVA_HOME to a 64-bit JDK
@echo.
) ELSE (
set IS_64bit=true
)
) ELSE ( ) ELSE (
set IS_64bit=true set IS_64bit=true
) )
@ -1126,7 +1130,6 @@ IF "%GC_TUNE%"=="" (
-XX:TargetSurvivorRatio=90 ^ -XX:TargetSurvivorRatio=90 ^
-XX:MaxTenuringThreshold=8 ^ -XX:MaxTenuringThreshold=8 ^
-XX:+UseConcMarkSweepGC ^ -XX:+UseConcMarkSweepGC ^
-XX:+UseParNewGC ^
-XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 ^ -XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 ^
-XX:+CMSScavengeBeforeRemark ^ -XX:+CMSScavengeBeforeRemark ^
-XX:PretenureSizeThreshold=64m ^ -XX:PretenureSizeThreshold=64m ^
@ -1913,8 +1916,8 @@ FOR /f "usebackq tokens=3" %%a IN (`^""%JAVA%" -version 2^>^&1 ^| findstr "versi
set JAVA_VERSION_INFO=!JAVA_VERSION_INFO:"=! set JAVA_VERSION_INFO=!JAVA_VERSION_INFO:"=!
REM Extract the major Java version, e.g. 7, 8, 9, 10 ... REM Extract the major Java version, e.g. 7, 8, 9, 10 ...
for /f "tokens=1,2 delims=." %%a in ("!JAVA_VERSION_INFO!") do ( for /f "tokens=1,2 delims=._-" %%a in ("!JAVA_VERSION_INFO!") do (
if "%%a" GEQ "9" ( if %%a GEQ 9 (
set JAVA_MAJOR_VERSION=%%a set JAVA_MAJOR_VERSION=%%a
) else ( ) else (
set JAVA_MAJOR_VERSION=%%b set JAVA_MAJOR_VERSION=%%b