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:15:53 UTC

[maven-jlink-plugin] branch MJLINK-62 created (now 91cc1cf)

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

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


      at 91cc1cf  [MJLINK-62] Use StringWriter for BAOS.

This branch includes the following new commits:

     new 91cc1cf  [MJLINK-62] Use StringWriter for BAOS.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-jlink-plugin] 01/01: [MJLINK-62] Use StringWriter for BAOS.

Posted by hb...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 91cc1cfec38b3863d578aa281e82b062819c3c92
Author: Benjamin Marwell <bm...@apache.org>
AuthorDate: Mon Dec 28 12:19:50 2020 +0100

    [MJLINK-62] Use StringWriter for BAOS.
---
 .../java9/org/apache/maven/plugins/jlink/JLinkExecutor.java | 13 +++++++------
 1 file changed, 7 insertions(+), 6 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 d562816..2b825ed 100644
--- a/src/main/java9/org/apache/maven/plugins/jlink/JLinkExecutor.java
+++ b/src/main/java9/org/apache/maven/plugins/jlink/JLinkExecutor.java
@@ -28,6 +28,7 @@ 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;
@@ -69,16 +70,16 @@ class JLinkExecutor extends AbstractJLinkToolchainExecutor
             getLog().debug( this.toolProvider.name() + " " + jlinkArgs );
         }
 
-        try ( ByteArrayOutputStream baosErr = new ByteArrayOutputStream();
-              PrintWriter err = new PrintWriter( baosErr );
-              ByteArrayOutputStream baosOut = new ByteArrayOutputStream();
-              PrintWriter out = new PrintWriter( baosOut ) )
+        try ( StringWriter strErr = new StringWriter();
+              PrintWriter err = new PrintWriter( strErr );
+              StringWriter strOut = new StringWriter();
+              PrintWriter out = new PrintWriter( strOut ) )
         {
             int exitCode = this.toolProvider.run( out, err, jlinkArgs.toArray( new String[0] ) );
             out.flush();
             err.flush();
 
-            String outAsString = baosOut.toString( "UTF-8" );
+            String outAsString = strOut.toString();
             String output = ( StringUtils.isEmpty( outAsString ) ? null : '\n' + outAsString.trim() );
 
             if ( exitCode != 0 )
@@ -95,7 +96,7 @@ class JLinkExecutor extends AbstractJLinkToolchainExecutor
 
                 StringBuilder msg = new StringBuilder( "\nExit code: " );
                 msg.append( exitCode );
-                String errAsString = baosErr.toString();
+                String errAsString = strErr.toString();
                 if ( StringUtils.isNotEmpty( errAsString ) )
                 {
                     msg.append( " - " ).append( errAsString );