[app-builder] fix: avoid NullPointerException for unknown HTTP status codes (#595) #596
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
🔗 相关问题 / Related Issue
Issue 链接 / Issue Link: #595
📋 变更类型 / Type of Change
📝 变更目的 / Purpose of Change
修复 DataMateKnowledgeBaseManager 和 QianfanKnowledgeBaseManager 中的空指针异常问题。当 HTTP 状态码不在 exceptionMap 中时,使用
get()方法会返回 null,导致调用.getMsg()时抛出 NullPointerException。Fix the NullPointerException issue in DataMateKnowledgeBaseManager and QianfanKnowledgeBaseManager. When the HTTP status code is not in the exceptionMap, using the
get()method returns null, causing a NullPointerException when calling.getMsg().📋 主要变更 / Brief Changelog
DataMateKnowledgeBaseManager: 使用
getOrDefault()替代get()方法,当状态码不存在时返回默认的 INTERNAL_SERVICE_ERRORQianfanKnowledgeBaseManager: 使用
getOrDefault()替代get()方法,当状态码不存在时返回默认的 INTERNAL_SERVICE_ERRORDataMateKnowledgeBaseManager: Use
getOrDefault()instead ofget()method, return default INTERNAL_SERVICE_ERROR when status code is not foundQianfanKnowledgeBaseManager: Use
getOrDefault()instead ofget()method, return default INTERNAL_SERVICE_ERROR when status code is not found🧪 验证变更 / Verifying this Change
测试步骤 / Test Steps
编译 data-mate-knowledge 模块:
mvn clean compile(成功)编译 qianfan-knowledge 模块:
mvn clean compile(成功)验证代码逻辑:当 statusCode 不在 exceptionMap 中时,返回 INTERNAL_SERVICE_ERROR 而不是抛出 NullPointerException
Compile data-mate-knowledge module:
mvn clean compile(passed)Compile qianfan-knowledge module:
mvn clean compile(passed)Verify code logic: When statusCode is not in exceptionMap, return INTERNAL_SERVICE_ERROR instead of throwing NullPointerException
测试覆盖 / Test Coverage
📸 截图 / Screenshots
不适用 / Not applicable
✅ 贡献者检查清单 / Contributor Checklist
基本要求 / Basic Requirements:
代码质量 / Code Quality:
测试要求 / Testing Requirements:
mvn -B clean package -Dmaven.test.skip=true,npm install --force && npm run build:pro/ Basic checks passmvn clean install/ Unit tests pass文档和兼容性 / Documentation and Compatibility:
📋 附加信息 / Additional Notes
这是一个简单的修复,仅修改了异常处理逻辑,不影响其他功能。修复后的代码使用
getOrDefault()方法,当状态码不存在时返回默认的 INTERNAL_SERVICE_ERROR,避免了空指针异常。This is a simple fix that only modifies the exception handling logic and does not affect other functionality. The fixed code uses the
getOrDefault()method, returning the default INTERNAL_SERVICE_ERROR when the status code is not found, avoiding the NullPointerException.审查者注意事项 / Reviewer Notes:
请重点关注异常处理逻辑是否正确,以及默认错误码的选择是否合理。
Please focus on whether the exception handling logic is correct and whether the default error code selection is reasonable.
🤖 Create by Agent