[ISSUE #6752] fix: encode SSE events as UTF-8 - #6930
Open
yykaue wants to merge 8 commits into
Open
Conversation
…d add corresponding unit tests
Aias00
approved these changes
Aug 22, 2026
Aias00
left a comment
Contributor
There was a problem hiding this comment.
PR #6930 Review — [ISSUE #6752] fix: encode SSE events as UTF-8
Verdict: APPROVE
Scope
SseEventFormatter.formatEvent / formatComment (shenyu-plugin-mcp-server): encode SSE
payloads with StandardCharsets.UTF_8 instead of the platform-default charset.
Verification
- Two production lines changed (
getBytes()→getBytes(StandardCharsets.UTF_8));import java.nio.charset.StandardCharsetsadded. SSE is a UTF-8 text stream, so this is the correct
encoding and removes a real corruption risk on ISO-8859-1 default-charset systems. - Regression test
SseEventFormatterTestadded: byte-levelassertArrayEqualsfor a non-ASCII
JSON event (你好,世界) and a non-ASCII comment (保持连接), compared against the expected
UTF-8 bytes. Directly reproduces the bug (fails under ISO-8859-1) and is fixed by the change. - No API/signature change; mock-reactive
MockServerWebExchangealready on classpath.
Notes
- Minimal, correct, well-tested. Approving.
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.
Fixes #6752.
SseEventFormatterpreviously used the platform-default charset when converting SSE events and comments to bytes. On systems where the default charset is not UTF-8, non-ASCII MCP payloads could be corrupted.Since Server-Sent Events are UTF-8 text streams, this PR:
StandardCharsets.UTF_8when encoding SSE events.StandardCharsets.UTF_8when encoding SSE comments.Verification
@Aias00 Could you please review this PR?