Skip to content

GROOVY-12155: decode process output streams using the native encoding#2700

Open
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy12155
Open

GROOVY-12155: decode process output streams using the native encoding#2700
paulk-asert wants to merge 1 commit into
apache:masterfrom
paulk-asert:groovy12155

Conversation

@paulk-asert

@paulk-asert paulk-asert commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 69.1143%. Comparing base (c9363db) to head (8a75dea).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
.../codehaus/groovy/runtime/ProcessGroovyMethods.java 97.0588% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@                Coverage Diff                 @@
##               master      #2700        +/-   ##
==================================================
+ Coverage     69.1083%   69.1143%   +0.0059%     
- Complexity      34235      34248        +13     
==================================================
  Files            1537       1537                
  Lines          129310     129377        +67     
  Branches        23478      23503        +25     
==================================================
+ Hits            89364      89418        +54     
+ Misses          31936      31935         -1     
- Partials         8010       8024        +14     
Files with missing lines Coverage Δ
.../codehaus/groovy/runtime/FlushingStreamWriter.java 53.8462% <100.0000%> (+8.3916%) ⬆️
.../codehaus/groovy/runtime/ProcessGroovyMethods.java 81.6794% <97.0588%> (+1.0209%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@testlens-app

testlens-app Bot commented Jul 13, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 8a75dea
▶️ Tests: 103831 executed
⚪️ Checks: 31/31 completed


Learn more about TestLens at testlens.app.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR (GROOVY-12155) updates Groovy’s Process GDK methods to decode/encode process streams using the OS native encoding by default (instead of Charset.defaultCharset()), with an opt-in system property override and new charset-aware overloads.

Changes:

  • Default Process.text, waitForProcessOutput, consumeProcessOutput, and waitForResult decoding now uses the OS native encoding (or groovy.process.encoding when set).
  • Added charset-accepting overloads for process stream consumption and result capture APIs.
  • Extended ProcessTest to validate charset override behavior, and modernized the mock process streams.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
src/test/groovy/groovy/ProcessTest.groovy Adds regression tests for native/process encoding behavior and updates MockProcess stream setup.
src/main/java/org/codehaus/groovy/runtime/ProcessGroovyMethods.java Implements native-encoding defaulting, groovy.process.encoding override, and new charset overloads for process stream APIs.
src/main/java/org/codehaus/groovy/runtime/FlushingStreamWriter.java Adds a charset-aware constructor to support explicit encoding for process stdin writes.

Comment on lines +140 to 143
public static String getText(Process self, Charset charset) throws IOException {
String text = IOGroovyMethods.getText(new BufferedReader(new InputStreamReader(self.getInputStream(), charset)));
closeStreams(self);
return text;
Comment on lines +94 to +97
void testProcessTextDefaultsToTheNativeEncoding() {
def bytes = [0xE9] as byte[]
def expected = new String(bytes, Charset.forName(System.getProperty("native.encoding")))
assert expected == new MockProcess(bytes).text
Comment on lines +110 to +114
void testProcessEncodingPropertyIgnoredWhenNotAValidCharset() {
System.setProperty(PROCESS_ENCODING, "no-such-charset")
def bytes = [0xE9] as byte[]
def expected = new String(bytes, Charset.forName(System.getProperty("native.encoding")))
assert expected == new MockProcess(bytes).text
Comment on lines 160 to 163
@AfterEach
void tearDown() {
System.clearProperty(PROCESS_ENCODING)
myProcess.destroy()
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.

3 participants