You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by hb...@apache.org on 2020/12/29 11:14:14 UTC

[maven-jlink-plugin] branch master updated: Revert "[MJLINK-62] Use StringWriter for BAOS."

This is an automated email from the ASF dual-hosted git repository.

hboutemy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new f9e3945  Revert "[MJLINK-62] Use StringWriter for BAOS."
f9e3945 is described below

commit f9e394518a1d948b43e3006f1e05ae0372698102
Author: Hervé Boutemy <hb...@apache.org>
AuthorDate: Tue Dec 29 12:13:49 2020 +0100

    Revert "[MJLINK-62] Use StringWriter for BAOS."
    
    This reverts commit f12ed2aecff8e5cd0dc27053fffdc23432a5e716.
---
 .../java9/org/apache/maven/plugins/jlink/JLinkExecutor.java | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/src/main/java9/org/apache/maven/plugins/jlink/JLinkExecutor.java b/src/main/java9/org/apache/maven/plugins/jlink/JLinkExecutor.java
index 2b825ed..d562816 100644
--- a/src/main/java9/org/apache/maven/plugins/jlink/JLinkExecutor.java
+++ b/src/main/java9/org/apache/maven/plugins/jlink/JLinkExecutor.java
@@ -28,7 +28,6 @@ import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.io.PrintWriter;
-import java.io.StringWriter;
 import java.util.List;
 import java.util.Optional;
 import java.util.spi.ToolProvider;
@@ -70,16 +69,16 @@ class JLinkExecutor extends AbstractJLinkToolchainExecutor
             getLog().debug( this.toolProvider.name() + " " + jlinkArgs );
         }
 
-        try ( StringWriter strErr = new StringWriter();
-              PrintWriter err = new PrintWriter( strErr );
-              StringWriter strOut = new StringWriter();
-              PrintWriter out = new PrintWriter( strOut ) )
+        try ( ByteArrayOutputStream baosErr = new ByteArrayOutputStream();
+              PrintWriter err = new PrintWriter( baosErr );
+              ByteArrayOutputStream baosOut = new ByteArrayOutputStream();
+              PrintWriter out = new PrintWriter( baosOut ) )
         {
             int exitCode = this.toolProvider.run( out, err, jlinkArgs.toArray( new String[0] ) );
             out.flush();
             err.flush();
 
-            String outAsString = strOut.toString();
+            String outAsString = baosOut.toString( "UTF-8" );
             String output = ( StringUtils.isEmpty( outAsString ) ? null : '\n' + outAsString.trim() );
 
             if ( exitCode != 0 )
@@ -96,7 +95,7 @@ class JLinkExecutor extends AbstractJLinkToolchainExecutor
 
                 StringBuilder msg = new StringBuilder( "\nExit code: " );
                 msg.append( exitCode );
-                String errAsString = strErr.toString();
+                String errAsString = baosErr.toString();
                 if ( StringUtils.isNotEmpty( errAsString ) )
                 {
                     msg.append( " - " ).append( errAsString );