Skip to content

[fix] Modify the startup script to fix the log and protobuf dependenc…#5

Open
kenssa4eedfd wants to merge 4 commits intohubble2from
hubble2-bugfix
Open

[fix] Modify the startup script to fix the log and protobuf dependenc…#5
kenssa4eedfd wants to merge 4 commits intohubble2from
hubble2-bugfix

Conversation

@kenssa4eedfd
Copy link
Collaborator

@kenssa4eedfd kenssa4eedfd commented Nov 27, 2025

…y conflict

Purpose of the PR

  • close #xxx

Main Changes

Verifying these changes

  • Trivial rework / code cleanup without any test coverage. (No Need)
  • Already covered by existing tests, such as (please modify tests here).
  • Need tests and can be verified as follows:
    • xxx

Does this PR potentially affect the following parts?

  • Nope
  • Dependencies (add/update license info)
  • Modify configurations
  • The public API
  • Other affects (typed here)

Documentation Status

  • Doc - TODO
  • Doc - Done
  • Doc - No Need

Summary by CodeRabbit

  • 缺陷修复

    • 改进启动脚本的 JAR 依赖管理:新增 Protobuf 库自动检测与纳入类路径、避免重复加载,并过滤不兼容的日志绑定以提升运行时兼容性。
    • 优化类路径初始化,减少不兼容日志绑定被加入运行时类路径。
  • 行为变更

    • 客户端构建器增强了对图标识的校验,图名不能为空,构建时需提供有效图标识。

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 27, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

新增对 protobuf-java-*.jar 的专门解析与类路径处理,并在脚本中排除特定日志绑定库;同时在 HugeClientBuilder 中添加对 graph 参数的非空/非空字符串校验(构造器与 build() 中均校验),若为空则报错。

Changes

内聚体 / 文件 变更摘要
Protobuf 与类路径管理
hugegraph-hubble/hubble-dist/assembly/static/bin/start-hubble.sh
新增在 LIB_PATH 下查找并保存 protobuf-java-*.jar 的解析步骤(PROTO_JAR),将类路径初始值改为 ".:${PROTO_JAR}",在遍历 LIB_PATH/*.jar 时跳过已添加的 PROTO_JAR,并在 JAR 循环中排除 log4j-to-slf4j-*logback-classic-*logback-core-* 等日志绑定包。
客户端构建参数校验
hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClientBuilder.java
graph 参数添加非空/非空字符串校验(在构造器和 build() 中均加入判断),在为空时抛出错误;未改变公开方法签名。

Sequence Diagram(s)

sequenceDiagram
    participant Starter as start-hubble.sh
    participant FS as 文件系统
    participant CL as ClasspathBuilder
    participant JVM as Java JVM

    Note over Starter,FS `#DDEEFF`: 启动脚本:protobuf 专门解析与过滤
    Starter->>FS: 搜索 LIB_PATH 中 protobuf-java-*.jar
    alt 找到 PROTO_JAR
        FS-->>Starter: 返回 PROTO_JAR 路径
        Starter->>CL: 初始 CLASSPATH = ".:${PROTO_JAR}"
    else 未找到
        FS-->>Starter: 无匹配
        Starter-->>Starter: 退出并报错
    end
    Starter->>FS: 遍历 LIB_PATH/*.jar(过滤日志绑定 & 跳过 PROTO_JAR)
    FS-->>CL: 追加合格的 jars 到 CLASSPATH
    CL->>JVM: 使用构建的 CLASSPATH 启动 Java 应用
Loading
sequenceDiagram
    participant Caller as 使用者
    participant Builder as HugeClientBuilder
    participant Validator as 校验逻辑

    Note over Caller,Builder `#E8F6E8`: 客户端构建:新增 graph 非空校验
    Caller->>Builder: new HugeClientBuilder(hosts, port, graph)
    Builder->>Validator: 检查 graph 非空且非空字符串
    alt graph 有效
        Validator-->>Builder: 通过
        Builder->>Caller: 返回 Builder 实例
        Caller->>Builder: build()
        Builder->>Validator: 再次检查 graph 非空
        Validator-->>Builder: 通过
        Builder-->>Caller: 返回 HugeClient
    else graph 为空/无效
        Validator-->>Builder: 抛出错误并终止
        Builder-->>Caller: 抛出异常
    end
Loading

预估代码审查工作量

🎯 3 (Moderate) | ⏱️ ~20 分钟

  • 重点检查 start-hubble.sh 中的文件匹配模式、错误分支、类路径拼接与重复跳过逻辑。
  • 验证日志绑定过滤规则不会误排除必要的 jar(注意 glob/正则在不同 shell 下的行为)。
  • 审查 HugeClientBuilder 的校验实现(异常类型、错误信息)及其对上游调用者契约的影响。

兔子之诗

🐇 我在库间轻嗅春光,
找到 protobuf 铺就长廊,
旧绑带被风卷走远方,
图名有守护,构建更稳当,
小耳摇摆,启动欢畅。 ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive PR标题部分相关但不够完整,指出了「启动脚本」和「日志与protobuf依赖」问题,但标题被截断且缺乏详细描述。 建议完整并明确标题,如:'Fix protobuf JAR resolution and filter logging bindings in startup script' 或 'Add graph validation in HugeClientBuilder'。
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch hubble2-bugfix

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link

Summary of Changes

Hello @kenssa4eedfd, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request focuses on enhancing the robustness of the HugeGraph-Hubble startup process by rectifying critical dependency conflicts. The changes ensure that the application's logging and Protobuf components initialize without issues, leading to a more stable and predictable runtime environment.

Highlights

  • Dependency Conflict Resolution: The startup script has been modified to explicitly address and resolve dependency conflicts related to logging and Protobuf libraries.
  • Protobuf Classpath Prioritization: The protobuf-java-*.jar is now specifically located and added to the classpath first, ensuring it is loaded correctly and preventing potential conflicts with other JARs.
  • SLF4J Binding Management: The script now filters out conflicting SLF4J binding implementations (like log4j-to-slf4j, logback-classic, and logback-core) to ensure only a single, intended SLF4J binding (presumably log4j-slf4j-impl) is used, preventing runtime errors due to multiple bindings.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the start-hubble.sh script to address dependency conflicts with protobuf and logging libraries. The changes ensure that a specific protobuf-java jar is prioritized in the classpath and that conflicting SLF4J logging bindings are excluded. My review includes a couple of suggestions to improve the script's efficiency and robustness. Overall, the changes are a good improvement.

PROTO_JAR=""
for jar in "${LIB_PATH}"/protobuf-java-*.jar; do
[[ -e "$jar" ]] || break
PROTO_JAR="$jar"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This loop iterates over all matching protobuf-java-*.jar files and assigns the last one to PROTO_JAR. It's more efficient to stop after finding the first one. You can add a break to exit the loop immediately after a match is found. This also makes the behavior more predictable if multiple versions of the jar exist, by always selecting the first one in lexicographical order.

Suggested change
PROTO_JAR="$jar"
PROTO_JAR="$jar"; break

Comment on lines 52 to 58
base=$(basename "$jar")
# Avoid multiple slf4j bindings: keep log4j-slf4j-impl, drop log4j-to-slf4j and logback
case "${base}" in
log4j-to-slf4j-*.jar|logback-classic-*.jar|logback-core-*.jar)
continue
;;
esac

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Calling basename inside a loop is inefficient as it starts a new process on each iteration. This can be optimized by using shell's built-in glob matching within the case statement, which avoids forking a process.

Suggested change
base=$(basename "$jar")
# Avoid multiple slf4j bindings: keep log4j-slf4j-impl, drop log4j-to-slf4j and logback
case "${base}" in
log4j-to-slf4j-*.jar|logback-classic-*.jar|logback-core-*.jar)
continue
;;
esac
# Avoid multiple slf4j bindings: keep log4j-slf4j-impl, drop log4j-to-slf4j and logback
case "$jar" in
*/log4j-to-slf4j-*.jar|*/logback-classic-*.jar|*/logback-core-*.jar)
continue
;;
esac

@imbajin imbajin requested a review from Copilot November 27, 2025 07:00
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@imbajin
Copy link

imbajin commented Nov 27, 2025

@coderabbitai full review

@coderabbitai
Copy link

coderabbitai bot commented Nov 27, 2025

✅ Actions performed

Full review triggered.

@imbajin
Copy link

imbajin commented Nov 27, 2025

@codecov-ai-reviewer review

@github-actions github-actions bot removed the client label Nov 27, 2025
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClientBuilder.java (1)

89-92: 建议在 configGraph() 中添加参数校验。

configGraph() 方法允许在构造后设置 graph 参数,但没有进行任何校验。这会破坏构造器建立的不变性约束(graph 必须非空且非空字符串)。调用者可以通过 configGraph(null)configGraph("") 绕过构造器的校验。

建议添加与构造器一致的校验逻辑:

 public HugeClientBuilder configGraph(String graph) {
+    E.checkArgument(graph != null && !graph.isEmpty(),
+                    "Expect a string value as the graph name parameter argument, but got: %s",
+                    graph);
     this.graph = graph;
     return this;
 }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bfdf2e8 and e2a1723.

📒 Files selected for processing (1)
  • hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClientBuilder.java (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (8)
  • GitHub Check: hubble-ci (11, 3.11)
  • GitHub Check: check-dependency-license
  • GitHub Check: loader-ci (11)
  • GitHub Check: client-ci (11)
  • GitHub Check: tools-ci (11)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: Analyze (java)
  • GitHub Check: spark-connector-ci (11)
🔇 Additional comments (1)
hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClientBuilder.java (1)

57-59: 做得好!添加了防御性参数校验。

在构造器中对 graph 参数进行非空且非空字符串的校验是良好的防御性编程实践,可以尽早捕获无效输入。错误消息清晰且与现有的 url 参数校验保持一致。


public HugeClient build() {
E.checkArgument(this.url != null, "The url parameter can't be null");
E.checkArgument(this.graph != null, "The graph parameter can't be null");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

校验逻辑与构造器不一致。

构造器(第 57-59 行)校验 graph 既不为 null 也不为空字符串,但此处仅校验非 null。如果在构造后调用 configGraph("")build() 方法不会捕获空字符串,导致校验逻辑不一致。

建议应用以下修复:

-        E.checkArgument(this.graph != null, "The graph parameter can't be null");
+        E.checkArgument(this.graph != null && !this.graph.isEmpty(),
+                        "The graph parameter can't be null or empty");
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
E.checkArgument(this.graph != null, "The graph parameter can't be null");
E.checkArgument(this.graph != null && !this.graph.isEmpty(),
"The graph parameter can't be null or empty");
🤖 Prompt for AI Agents
In
hugegraph-client/src/main/java/org/apache/hugegraph/driver/HugeClientBuilder.java
around line 80, the build() method only checks graph != null but the constructor
validated graph is neither null nor empty; update the check to require the graph
be non-null and not empty (preferably after trimming) so build() rejects
empty-string graphs the same way as the constructor, and update the error
message accordingly.

@github-actions
Copy link

Due to the lack of activity, the current pr is marked as stale and will be closed after 180 days, any update will remove the stale label

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants