[MSHARED-619] StreamFeeder silently ignores exceptions.
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1784430 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java b/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java
index 8409eeb..1655c78 100644
--- a/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java
+++ b/src/main/java/org/apache/maven/shared/utils/cli/StreamFeeder.java
@@ -33,25 +33,26 @@
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 @@
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 @@
}
}
- // ----------------------------------------------------------------------
- //
- // ----------------------------------------------------------------------
-
public void close()
{
setDone();
@@ -90,7 +91,10 @@
}
catch ( IOException ex )
{
- // ignore
+ if ( this.exception != null )
+ {
+ this.exception = ex;
+ }
}
}
@@ -103,14 +107,21 @@
}
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()