Skip to content

Fix platform-dependent encoding in CLI process stream readers#21

Merged
brunoborges merged 2 commits intomainfrom
copilot/fix-default-encoding-issue
Feb 6, 2026
Merged

Fix platform-dependent encoding in CLI process stream readers#21
brunoborges merged 2 commits intomainfrom
copilot/fix-default-encoding-issue

Conversation

Copy link
Contributor

Copilot AI commented Feb 6, 2026

SpotBugs identified two instances where InputStreamReader relied on platform default encoding when reading from CLI process streams, causing potential character interpretation differences across systems.

Changes

  • Added explicit StandardCharsets.UTF_8 charset parameter to both InputStreamReader instantiations in startCliServer():
    • stderr forwarding thread (line 1018)
    • port announcement reader (line 1034)

Before:

new InputStreamReader(process.getErrorStream())

After:

new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8)

Resolves DM_DEFAULT_ENCODING / CWE-173 findings.

Original prompt

This section details on the original issue you should resolve

<issue_title>SpotBugs: Reliance on default encoding in CopilotClient</issue_title>
<issue_description>## SpotBugs Finding: DM_DEFAULT_ENCODING

Category: I18N (Internationalization)
Priority: 1 (High) | Rank: 19
Bug Type: DM_DEFAULT_ENCODING
CWE: CWE-173
Instances: 2

Description

Found reliance on default encoding via new InputStreamReader(InputStream) without specifying a charset. This can lead to different behavior across platforms with different default encodings.

Affected Locations

Class Method File Line
CopilotClient lambda$startCliServer$0(Process) CopilotClient.java 1017
CopilotClient startCliServer() CopilotClient.java 1032

Suggested Fix

// Before:
new InputStreamReader(process.getErrorStream())

// After:
new InputStreamReader(process.getErrorStream(), StandardCharsets.UTF_8)

Generated from SpotBugs 4.9.8 static analysis</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix reliance on default encoding in CopilotClient Fix platform-dependent encoding in CLI process stream readers Feb 6, 2026
Copilot AI requested a review from brunoborges February 6, 2026 02:03
@brunoborges brunoborges marked this pull request as ready for review February 6, 2026 02:04
@brunoborges brunoborges merged commit 2a2366a into main Feb 6, 2026
2 checks passed
@brunoborges brunoborges deleted the copilot/fix-default-encoding-issue branch February 16, 2026 15:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SpotBugs: Reliance on default encoding in CopilotClient

2 participants