maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From schu...@apache.org
Subject svn commit: r1784430 - /maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java
Date Sun, 26 Feb 2017 10:08:14 GMT
Author: schulte
Date: Sun Feb 26 10:08:13 2017
New Revision: 1784430

URL: http://svn.apache.org/viewvc?rev=1784430&view=rev
Log:
[MSHARED-619] StreamFeeder silently ignores exceptions.


Modified:
    maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java

Modified: maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java?rev=1784430&r1=1784429&r2=1784430&view=diff
==============================================================================
--- maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java
(original)
+++ maven/shared/trunk/maven-shared-utils/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java
Sun Feb 26 10:08:13 2017
@@ -33,25 +33,26 @@ import java.util.concurrent.atomic.Atomi
 class StreamFeeder
     extends AbstractStreamHandler
 {
+
     private final AtomicReference<InputStream> input;
+
     private final AtomicReference<OutputStream> output;
 
+    private volatile Throwable exception;
+
     /**
      * Create a new StreamFeeder
      *
-     * @param input  Stream to read from
+     * @param input Stream to read from
      * @param output Stream to write to
      */
     public StreamFeeder( InputStream input, OutputStream output )
     {
+        super();
         this.input = new AtomicReference<InputStream>( input );
         this.output = new AtomicReference<OutputStream>( output );
     }
 
-    // ----------------------------------------------------------------------
-    // Runnable implementation
-    // ----------------------------------------------------------------------
-
     @Override
     public void run()
     {
@@ -62,6 +63,10 @@ class StreamFeeder
         catch ( Throwable e )
         {
             // Catch everything so the streams will be closed and flagged as done.
+            if ( this.exception != null )
+            {
+                this.exception = e;
+            }
         }
         finally
         {
@@ -74,10 +79,6 @@ class StreamFeeder
         }
     }
 
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
-
     public void close()
     {
         setDone();
@@ -90,7 +91,10 @@ class StreamFeeder
             }
             catch ( IOException ex )
             {
-                // ignore
+                if ( this.exception != null )
+                {
+                    this.exception = ex;
+                }
             }
         }
 
@@ -103,14 +107,21 @@ class StreamFeeder
             }
             catch ( IOException ex )
             {
-                // ignore
+                if ( this.exception != null )
+                {
+                    this.exception = ex;
+                }
             }
         }
     }
 
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
+    /**
+     * @since 3.2.0
+     */
+    public Throwable getException()
+    {
+        return this.exception;
+    }
 
     @SuppressWarnings( "checkstyle:innerassignment" )
     private void feed()



Mime
View raw message