fix(server): Handle empty lines in server list response#152
Open
quzard wants to merge 1 commit intonacos-group:masterfrom
Open
fix(server): Handle empty lines in server list response#152quzard wants to merge 1 commit intonacos-group:masterfrom
quzard wants to merge 1 commit intonacos-group:masterfrom
Conversation
**Motivation:** The current server list parsing logic in `ServerListManager` is not resilient to empty lines in the server response. A response with a trailing newline (e.g., `1.1.1.1:8848\n2.2.2.2:8848\n`) would result in an empty string after splitting, which could cause parsing errors or undefined behavior downstream. **Changes:** 1. **Add a guard:** Skip empty strings during the parsing loop to prevent errors. 2. **Add a debug log:** Output the raw server list content to make it easier to diagnose server response issues in the future. This improves the overall stability of the server discovery mechanism.
修复服务器列表解析时空行导致的错误变更概述问题修复
变更文件
时序图sequenceDiagram
participant Client as Nacos Client
participant SLM as ServerListManager
participant Utils as ParamUtils
Client->>SLM: 请求服务器列表
SLM->>Utils: 拆分服务器响应内容(按换行符)
Utils-->>SLM: 返回包含空元素的字符串列表
SLM->>SLM: 过滤空元素并记录原始内容
SLM-->>Client: 返回有效服务器列表
💡 小贴士与 lingma-agents 交流的方式📜 直接回复评论
📜 在代码行处标记
📜 在讨论中提问
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Motivation:
The current server list parsing logic in
ServerListManageris not resilient to empty lines in the server response. A response with a trailing newline (e.g.,1.1.1.1:8848\n2.2.2.2:8848\n) would result in an empty string after splitting, which could cause parsing errors or undefined behavior downstream.Changes:
This improves the overall stability of the server discovery mechanism.