Specify UTF-8 charset explicitly in STDIO transport InputStreamReader#826
Open
xxxxxxjun wants to merge 6 commits intomodelcontextprotocol:mainmodelcontextprotocol/java-sdk:mainfrom
xxxxxxjun:fix/stdio-encoding-inconsistencyxxxxxxjun/java-sdk:fix/stdio-encoding-inconsistencyCopy head branch name to clipboard
Open
Specify UTF-8 charset explicitly in STDIO transport InputStreamReader#826xxxxxxjun wants to merge 6 commits intomodelcontextprotocol:mainmodelcontextprotocol/java-sdk:mainfrom xxxxxxjun:fix/stdio-encoding-inconsistencyxxxxxxjun/java-sdk:fix/stdio-encoding-inconsistencyCopy head branch name to clipboard
xxxxxxjun wants to merge 6 commits intomodelcontextprotocol:mainmodelcontextprotocol/java-sdk:mainfrom
xxxxxxjun:fix/stdio-encoding-inconsistencyxxxxxxjun/java-sdk:fix/stdio-encoding-inconsistencyCopy head branch name to clipboard
Conversation
a34570a to
a4b1102
Compare
Member
|
As explained in #295 (comment), a valid contribution would include a test verifying that the solution is correct. Thank you. |
Verifies that multi-byte UTF-8 characters (Korean, emoji, accented Latin, Japanese) are correctly preserved through the STDIO inbound processing pipeline.
Use natural script names (한글, 漢字) and a common accented word (café) for UTF-8 encoding test data.
Author
|
@chemicL Thank you for the feedback. I've added a test that verifies multi-byte UTF-8 characters are correctly preserved through the STDIO inbound processing pipeline. |
chemicL
reviewed
Feb 21, 2026
|
|
||
| @Test | ||
| @SuppressWarnings("unchecked") | ||
| void shouldHandleUtf8EncodedMessages() throws Exception { |
Member
There was a problem hiding this comment.
the test passes without the changes.
The test passes regardless of whether UTF-8 is explicitly specified, because the test environment default charset is already UTF-8.
Spawns a child JVM with -Dfile.encoding=ISO-8859-1 to simulate a non-UTF-8 default charset environment. The test sends a JSON-RPC message containing multi-byte characters (Korean, Chinese, accented Latin, emoji) through StdioServerTransportProvider and verifies they are preserved. This test fails without the explicit UTF-8 charset fix and passes with it.
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.
Add explicit UTF-8 charset to InputStreamReader in STDIO transports.
Resolves #295
Motivation and Context
Input streams in StdioClientTransport and StdioServerTransportProvider were missing explicit UTF-8 charset, while output streams already specify it.
How Has This Been Tested?
Existing STDIO transport tests pass locally.
Breaking Changes
No
Types of changes
Checklist
Additional context
AI tools were used for drafting the PR description.