diff --git a/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java b/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java index 2ffcfb24..5331567e 100644 --- a/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java +++ b/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java @@ -280,11 +280,11 @@ public Integer call() inputFeeder.start(); } - outputPumper = new StreamPumper( p.getInputStream(), systemOut ); + outputPumper = new StreamPumper( p.getInputStream(), systemOut , streamCharset ); outputPumper.setName( "StreamPumper-systemOut" ); outputPumper.start(); - errorPumper = new StreamPumper( p.getErrorStream(), systemErr ); + errorPumper = new StreamPumper( p.getErrorStream(), systemErr , streamCharset ); errorPumper.setName( "StreamPumper-systemErr" ); errorPumper.start(); diff --git a/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java b/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java index 079d0d16..fb58a97f 100644 --- a/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java +++ b/src/test/java/org/apache/maven/shared/utils/cli/CommandLineUtilsTest.java @@ -24,6 +24,7 @@ import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; +import java.nio.charset.Charset; import java.util.Arrays; import java.util.HashMap; import java.util.Locale; @@ -168,4 +169,25 @@ private void assertCmdLineArgs( final String[] expected, final String cmdLine ) assertEquals( expected.length, actual.length ); assertEquals( Arrays.asList( expected ), Arrays.asList( actual ) ); } + + @Test + public void testChineseEncodingIssue() + throws Exception + { + Commandline commandline = new Commandline( "echo 金色传说" ); + StreamConsumer err = new StreamConsumer() { + @Override + public void consumeLine( String line ) { + + } + }; + StreamConsumer out = new StreamConsumer() { + @Override + public void consumeLine( String line ) { + System.out.println( line ); + } + }; + CommandLineCallable commandLineCallable = CommandLineUtils.executeCommandLineAsCallable( commandline, null, out, err, 10, null, Charset.forName("GBK") ); + commandLineCallable.call(); + } }