Skip to content

Commit 74f3d32

Browse files
committed
fix:
fix the bug in JDK version comparison
1 parent 0946d5d commit 74f3d32

File tree

1 file changed

+10
-3
lines changed
  • hugegraph-server/hugegraph-dist/src/assembly/static/bin

1 file changed

+10
-3
lines changed

hugegraph-server/hugegraph-dist/src/assembly/static/bin/init-store.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,16 @@ cd "${TOP}" || exit
4747

4848
DEFAULT_JAVA_OPTIONS=""
4949
JAVA_VERSION=$($JAVA -version 2>&1 | awk 'NR==1{gsub(/"/,""); print $3}' | awk -F'_' '{print $1}')
50-
# TODO: better not string number compare, use `bc` like github.com/koalaman/shellcheck/wiki/SC2072
51-
if [[ $? -eq 0 && $JAVA_VERSION > "1.9" ]]; then
52-
DEFAULT_JAVA_OPTIONS="--add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED"
50+
51+
# 提取主版本号进行数值比较
52+
if [[ $JAVA_VERSION == 1.* ]]; then
53+
MAJOR_VERSION=$(echo $JAVA_VERSION | cut -d'.' -f2)
54+
else
55+
MAJOR_VERSION=$(echo $JAVA_VERSION | cut -d'.' -f1)
56+
fi
57+
58+
if [[ $? -eq 0 && $MAJOR_VERSION -ge 9 ]]; then
59+
DEFAULT_JAVA_OPTIONS="--add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED"
5360
fi
5461

5562
echo "Initializing HugeGraph Store..."

0 commit comments

Comments
 (0)