maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From schu...@apache.org
Subject svn commit: r1784357 - in /maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli: CommandLineUtils.java DefaultConsumer.java StreamConsumer.java StreamPumper.java WriterStreamConsumer.java javatool/AbstractJavaTool.java
Date Sat, 25 Feb 2017 08:11:19 GMT
Author: schulte
Date: Sat Feb 25 08:11:19 2017
New Revision: 1784357

URL: http://svn.apache.org/viewvc?rev=1784357&view=rev
Log:
o Updated method 'consumeLine(String)' of the 'StreamConsumer' interface adding
  'IOException' to the list of declared exceptions to allow implementors to
  report any failures when consuming a line fails.


Modified:
    maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
    maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/DefaultConsumer.java
    maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamConsumer.java
    maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java
    maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/WriterStreamConsumer.java
    maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java?rev=1784357&r1=1784356&r2=1784357&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
(original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/CommandLineUtils.java
Sat Feb 25 08:11:19 2017
@@ -52,6 +52,7 @@ public abstract class CommandLineUtils
         private static final String LS = System.getProperty( "line.separator" );
 
         /** {@inheritDoc} */
+        @Override
         public void consumeLine( String line )
         {
             string.append( line ).append( LS );

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/DefaultConsumer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/DefaultConsumer.java?rev=1784357&r1=1784356&r2=1784357&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/DefaultConsumer.java
(original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/DefaultConsumer.java
Sat Feb 25 08:11:19 2017
@@ -19,6 +19,8 @@ package org.apache.maven.shared.utils.cl
  * under the License.
  */
 
+import java.io.IOException;
+
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @version $Id$
@@ -26,9 +28,18 @@ package org.apache.maven.shared.utils.cl
 public class DefaultConsumer
     implements StreamConsumer
 {
-    /** {@inheritDoc} */
-    public void consumeLine( String line )
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void consumeLine( String line ) throws IOException
     {
         System.out.println( line );
+        if ( System.out.checkError() )
+        {
+            throw new IOException( String.format( "Failure writing line '%s' to stdout.",
line ) );
+        }
     }
+
 }

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamConsumer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamConsumer.java?rev=1784357&r1=1784356&r2=1784357&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamConsumer.java
(original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamConsumer.java
Sat Feb 25 08:11:19 2017
@@ -19,6 +19,8 @@ package org.apache.maven.shared.utils.cl
  * under the License.
  */
 
+import java.io.IOException;
+
 /**
  * Works in concert with the StreamPumper class to
  * allow implementations to gain access to the lines being
@@ -35,6 +37,7 @@ public interface StreamConsumer
     /**
      * Called when the StreamPumper pumps a line from the Stream.
      * @param line The line to be consumed.
+     * @throws IOException if consuming {@code line} fails.
      */
-    void consumeLine( String line );
+    void consumeLine( String line ) throws IOException;
 }

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java?rev=1784357&r1=1784356&r2=1784357&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java
(original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamPumper.java
Sat Feb 25 08:11:19 2017
@@ -145,7 +145,7 @@ public class StreamPumper
         return exception;
     }
 
-    private void consumeLine( String line )
+    private void consumeLine( String line ) throws IOException
     {
         if ( consumer != null && !isDisabled() )
         {

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/WriterStreamConsumer.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/WriterStreamConsumer.java?rev=1784357&r1=1784356&r2=1784357&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/WriterStreamConsumer.java
(original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/WriterStreamConsumer.java
Sat Feb 25 08:11:19 2017
@@ -19,7 +19,8 @@ package org.apache.maven.shared.utils.cl
  * under the License.
  */
 
-import java.io.PrintWriter;
+import java.io.BufferedWriter;
+import java.io.IOException;
 import java.io.Writer;
 
 /**
@@ -30,22 +31,26 @@ public class WriterStreamConsumer
     implements StreamConsumer
 {
 
-    private final PrintWriter writer;
+    private final BufferedWriter writer;
 
     /**
      * @param writer {@link Writer}
      */
     public WriterStreamConsumer( Writer writer )
     {
-        this.writer = new PrintWriter( writer );
+        super();
+        this.writer = new BufferedWriter( writer );
     }
 
-    /** {@inheritDoc}
+    /**
+     * {@inheritDoc}
      */
-    public void consumeLine( String line )
+    @Override
+    public void consumeLine( String line ) throws IOException
     {
-        writer.println( line );
-
-        writer.flush();
+        this.writer.append( line );
+        this.writer.newLine();
+        this.writer.flush();
     }
+
 }

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java?rev=1784357&r1=1784356&r2=1784357&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
(original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/javatool/AbstractJavaTool.java
Sat Feb 25 08:11:19 2017
@@ -199,6 +199,7 @@ public abstract class AbstractJavaTool<R
                 /**
                  * {@inheritDoc}
                  */
+                @Override
                 public void consumeLine( final String line )
                 {
                     getLogger().warn( line );
@@ -226,6 +227,7 @@ public abstract class AbstractJavaTool<R
                 /**
                  * {@inheritDoc}
                  */
+                @Override
                 public void consumeLine( final String line )
                 {
                     getLogger().info( line );



Mime
View raw message