You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by us...@apache.org on 2018/03/27 20:49:48 UTC

lucene-solr:master: 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

Repository: lucene-solr
Updated Branches:
  refs/heads/master 08686038e -> ade2cf2e7


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.


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/ade2cf2e
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/ade2cf2e
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/ade2cf2e

Branch: refs/heads/master
Commit: ade2cf2e742fc4f2c312064df9e1ac78159bb23a
Parents: 0868603
Author: Uwe Schindler <us...@apache.org>
Authored: Tue Mar 27 22:49:23 2018 +0200
Committer: Uwe Schindler <us...@apache.org>
Committed: Tue Mar 27 22:49:23 2018 +0200

----------------------------------------------------------------------
 solr/CHANGES.txt  |  4 ++++
 solr/bin/solr     | 15 +++++++--------
 solr/bin/solr.cmd | 21 ++++++++++++---------
 3 files changed, 23 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ade2cf2e/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index f6fe612..3039ce3 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -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-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
 ----------------------
 

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ade2cf2e/solr/bin/solr
----------------------------------------------------------------------
diff --git a/solr/bin/solr b/solr/bin/solr
index e05d570..6487540 100755
--- a/solr/bin/solr
+++ b/solr/bin/solr
@@ -50,7 +50,7 @@ verbose=false
 THIS_OS=`uname -s`
 
 # What version of Java is required to run this version of Solr.
-JAVA_VER_REQ="1.8"
+JAVA_VER_REQ="8"
 
 stop_all=false
 
@@ -138,10 +138,10 @@ if [[ $? -ne 0 ]] ; then
   echo >&2 "${PATH}"
   exit 1
 else
-  JAVA_VER_NUM=$(echo $JAVA_VER | head -1 | awk -F '"' '/version/ {print $2}')
-  if [[ "$JAVA_VER_NUM" < "$JAVA_VER_REQ" ]] ; then
-    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:"
+  JAVA_VER_NUM=$(echo $JAVA_VER | head -1 | awk -F '"' '/version/ {print $2}' | sed -e's/^1\.//' | sed -e's/[._-].*$//')
+  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 "We found major version $JAVA_VER_NUM, using command '${JAVA} -version', with response:"
     echo >&2 "${JAVA_VER}"
     echo >&2
     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)
 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' \
                  '-XX:+PrintGCDateStamps' '-XX:+PrintGCTimeStamps' '-XX:+PrintTenuringDistribution' \
                  '-XX:+PrintGCApplicationStoppedTime')
@@ -1841,7 +1841,7 @@ fi
 
 # if verbose gc logging enabled, setup the location of the log file and rotation
 if [ "$GC_LOG_OPTS" != "" ]; then
-  if [[ "$JAVA_VER_NUM" < "9" ]] ; then
+  if [[ "$JAVA_VER_NUM" -lt "9" ]] ; then
     gc_log_flag="-Xloggc"
     if [ "$JAVA_VENDOR" == "IBM J9" ]; then
       gc_log_flag="-Xverbosegclog"
@@ -1953,7 +1953,6 @@ function launch_solr() {
         '-XX:TargetSurvivorRatio=90' \
         '-XX:MaxTenuringThreshold=8' \
         '-XX:+UseConcMarkSweepGC' \
-        '-XX:+UseParNewGC' \
         '-XX:ConcGCThreads=4' '-XX:ParallelGCThreads=4' \
         '-XX:+CMSScavengeBeforeRemark' \
         '-XX:PretenureSizeThreshold=64m' \

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/ade2cf2e/solr/bin/solr.cmd
----------------------------------------------------------------------
diff --git a/solr/bin/solr.cmd b/solr/bin/solr.cmd
index 35e6ae9..15c4b50 100644
--- a/solr/bin/solr.cmd
+++ b/solr/bin/solr.cmd
@@ -178,7 +178,7 @@ IF NOT EXIST "%JAVA_HOME%\bin\java.exe" (
 set "JAVA=%JAVA_HOME%\bin\java"
 CALL :resolve_java_info
 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
 )
 
@@ -1057,11 +1057,15 @@ IF ERRORLEVEL 1 (
   set IS_JDK=true
   set "SERVEROPT=-server"
 )
-"%JAVA%" -d64 -version > nul 2>&1
-IF ERRORLEVEL 1 (
-  set "IS_64BIT=false"
-  @echo WARNING: 32-bit Java detected. Not recommended for production. Point your JAVA_HOME to a 64-bit JDK
-  @echo.
+if !JAVA_MAJOR_VERSION! LSS 9  (
+  "%JAVA%" -d64 -version > nul 2>&1
+  IF ERRORLEVEL 1 (
+    set "IS_64BIT=false"
+    @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 (
   set IS_64bit=true
 )
@@ -1126,7 +1130,6 @@ IF "%GC_TUNE%"=="" (
    -XX:TargetSurvivorRatio=90 ^
    -XX:MaxTenuringThreshold=8 ^
    -XX:+UseConcMarkSweepGC ^
-   -XX:+UseParNewGC ^
    -XX:ConcGCThreads=4 -XX:ParallelGCThreads=4 ^
    -XX:+CMSScavengeBeforeRemark ^
    -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:"=!
 
   REM Extract the major Java version, e.g. 7, 8, 9, 10 ...
-  for /f "tokens=1,2 delims=." %%a in ("!JAVA_VERSION_INFO!") do (
-    if "%%a" GEQ "9" (
+  for /f "tokens=1,2 delims=._-" %%a in ("!JAVA_VERSION_INFO!") do (
+    if %%a GEQ 9 (
       set JAVA_MAJOR_VERSION=%%a
     ) else (
       set JAVA_MAJOR_VERSION=%%b