qushencn opened a new issue, #2879:
URL: https://github.com/apache/incubator-hugegraph/issues/2879

   ### Bug Type (问题类型)
   
   None
   
   ### Before submit
   
   - [x] 我已经确认现有的 [Issues](https://github.com/apache/hugegraph/issues) 与 
[FAQ](https://hugegraph.apache.org/docs/guides/faq/) 中没有相同 / 重复问题 (I have 
confirmed and searched that there are no similar problems in the historical 
issue and documents)
   
   ### Environment (环境信息)
   
   - Server Version: 1.5.0
   - jdk版本:openjdk version "11.0.23" 2024-04-16 LTS
   
   
   ### Expected & Actual behavior (期望与实际表现)
   
   if [[ $? -eq 0 && $JAVA_VERSION >  "1.9" ]]; then
   HugeGraph 1.5.0 脚本中的版本判断逻辑存在缺陷:Shell 的字符串比较无法正确识别 11.0.23 大于 
1.9,导致条件分支未执行,参数未添加,最终触发权限报错。
   
   Shell 中的字符串比较(>)是按字典顺序而非数字逻辑比较的。对于版本号 11.0.27 和 1.9:
   字典比较时,先比较第一个字符 1(两者相同);
   再比较第二个字符:11.0.27 的第二个字符是 1,1.9 的第二个字符是 .(点号);
   在 ASCII 码中,. 的优先级高于 1,因此 Shell 会认为 11.0.27 小于 1.9,导致条件判断失败。
   
   
   优化:
   # 获取 Java 主版本号(如 11、8、7)
   JAVA_MAJOR_VERSION=$($JAVA -version 2>&1 | awk -F '"' '/version/ {split($2, 
arr, "."); if (arr[1] == "1") print arr[2]; else print arr[1]}')
   
   # 打印主版本号(调试用)
   echo "Debug: JAVA_MAJOR_VERSION = $JAVA_MAJOR_VERSION"
   
   # 数字比较:若主版本 > 9,则添加参数
   if [[ $JAVA_MAJOR_VERSION -gt 9 ]]; then
       
DEFAULT_JAVA_OPTIONS="--add-exports=java.base/jdk.internal.reflect=ALL-UNNAMED"
       echo "Debug: 主版本 > 9,添加参数"
   else
       DEFAULT_JAVA_OPTIONS=""
       echo "Debug: 主版本 <= 9,不添加参数"
   fi
   
   # 打印最终参数
   echo "Debug: DEFAULT_JAVA_OPTIONS = $DEFAULT_JAVA_OPTIONS"
   
   ### Vertex/Edge example (问题点 / 边数据举例)
   
   ```javascript
   
   ```
   
   ### Schema [VertexLabel, EdgeLabel, IndexLabel] (元数据结构)
   
   ```javascript
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to