Skip to content

Commit

Permalink
[fix][env] Support the java version like 'XX-internal' in env file (a…
Browse files Browse the repository at this point in the history
…pache#16008)

* [fix][env] Support the java version like 'XX-internal' in env file

* Adjust bkenv.sh

* Remove unnecessary dot.
  • Loading branch information
lgxbslgx authored Jun 14, 2022
1 parent eb9e0aa commit 0a58f58
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion conf/bkenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,17 @@ else
JAVA_BIN="$JAVA_HOME/bin/java"
fi
for token in $("$JAVA_BIN" -version 2>&1 | grep 'version "'); do
if [[ $token =~ \"([[:digit:]]+)\.([[:digit:]]+)\.(.*)\" ]]; then
if [[ $token =~ \"([[:digit:]]+)\.([[:digit:]]+)(.*)\" ]]; then
if [[ ${BASH_REMATCH[1]} == "1" ]]; then
JAVA_MAJOR_VERSION=${BASH_REMATCH[2]}
else
JAVA_MAJOR_VERSION=${BASH_REMATCH[1]}
fi
break
elif [[ $token =~ \"([[:digit:]]+)(.*)\" ]]; then
# Process the java versions without dots, such as `17-internal`.
JAVA_MAJOR_VERSION=${BASH_REMATCH[1]}
break
fi
done

Expand Down
6 changes: 5 additions & 1 deletion conf/pulsar_env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ else
JAVA_BIN="$JAVA_HOME/bin/java"
fi
for token in $("$JAVA_BIN" -version 2>&1 | grep 'version "'); do
if [[ $token =~ \"([[:digit:]]+)\.([[:digit:]]+)\.(.*)\" ]]; then
if [[ $token =~ \"([[:digit:]]+)\.([[:digit:]]+)(.*)\" ]]; then
if [[ ${BASH_REMATCH[1]} == "1" ]]; then
JAVA_MAJOR_VERSION=${BASH_REMATCH[2]}
else
JAVA_MAJOR_VERSION=${BASH_REMATCH[1]}
fi
break
elif [[ $token =~ \"([[:digit:]]+)(.*)\" ]]; then
# Process the java versions without dots, such as `17-internal`.
JAVA_MAJOR_VERSION=${BASH_REMATCH[1]}
break
fi
done

Expand Down

0 comments on commit 0a58f58

Please sign in to comment.