Details
Description
When the environment variable _JAVA_OPTIONS is set, solr fails with the following error:
$ solr -i Your current version of Java is too old to run this version of Solr. We found major version , using command '/opt/homebrew/opt/openjdk/libexec/openjdk.jdk/Contents/Home/bin/java -version', with response: Picked up _JAVA_OPTIONS: -Duser.home=/Users/brew/Library/Caches/Homebrew/java_cache -Djava.io.tmpdir=/private/tmp openjdk version "19.0.2" 2023-01-17 OpenJDK Runtime Environment Homebrew (build 19.0.2) OpenJDK 64-Bit Server VM Homebrew (build 19.0.2, mixed mode, sharing) Please install latest version of Java 11 or set JAVA_HOME properly.
This is because in the following version check logic (taken from here), only first line of java -version output is examined:
JAVA_VER_NUM=$(echo "$JAVA_VER" | head -1 | awk -F '"' '/version/ {print $2}' | sed -e's/^1\.//' | sed -e's/[._-].*$//')
But as indicated in the output above, java outputs "Picked up _JAVA_OPTIONS" on the first line instead, if _JAVA_OPTIONS is set. So, the version on the second line is not picked up.
I believe that it's this recent change (SOLR-9509), which added a pair of quotes around $JAVA_VER, that introduced this regression. This used to work in an unintended way, because Bash treated the unquoted $JAVA_VER variable as an array of separate arguments and output that in a single line. But after introducing the double quotes, the newlines in $JAVA_VER are now preserved.
$ JAVA_VER="$(java -version 2>&1)" $ echo $JAVA_VER Picked up _JAVA_OPTIONS: -Duser.home=/Users/ruoyu/Library/Caches/Homebrew/java_cache -Djava.io.tmpdir=/private/tmp openjdk version "19.0.2" 2023-01-17 OpenJDK Runtime Environment Homebrew (build 19.0.2) OpenJDK 64-Bit Server VM Homebrew (build 19.0.2, mixed mode, sharing) $ echo "$JAVA_VER" Picked up _JAVA_OPTIONS: -Duser.home=/Users/ruoyu/Library/Caches/Homebrew/java_cache -Djava.io.tmpdir=/private/tmp openjdk version "19.0.2" 2023-01-17 OpenJDK Runtime Environment Homebrew (build 19.0.2) OpenJDK 64-Bit Server VM Homebrew (build 19.0.2, mixed mode, sharing)
Attachments
Issue Links
- links to