Repository: ant
Updated Branches:
  refs/heads/1.9.x 38a22b0cf -> 0d3069327


properly verify preconditions in PumpStreamHandler

https://bz.apache.org/bugzilla/show_bug.cgi?id=62148


Project: http://git-wip-us.apache.org/repos/asf/ant/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant/commit/0d306932
Tree: http://git-wip-us.apache.org/repos/asf/ant/tree/0d306932
Diff: http://git-wip-us.apache.org/repos/asf/ant/diff/0d306932

Branch: refs/heads/1.9.x
Commit: 0d30693274fbae7282ca345a1374d9060008682d
Parents: 38a22b0
Author: Stefan Bodewig <bode...@apache.org>
Authored: Tue Apr 17 11:28:28 2018 +0200
Committer: Stefan Bodewig <bode...@apache.org>
Committed: Tue Apr 17 11:28:28 2018 +0200

----------------------------------------------------------------------
 WHATSNEW                                        | 10 ++++++++
 .../tools/ant/taskdefs/PumpStreamHandler.java   | 24 ++++++++++++--------
 2 files changed, 24 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ant/blob/0d306932/WHATSNEW
----------------------------------------------------------------------
diff --git a/WHATSNEW b/WHATSNEW
index 4a75837..a40c4ed 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -13,6 +13,16 @@ Fixed bugs:
  * The junit task when used with includeantruntime="no" was incorrectly
    printing a warning about multiple versions of ant detected in path
 
+Other changes:
+--------------
+
+ * PumpStreamHandler now explicitly verifies the streams for output
+   and error are not null and will throw an exception if they
+   are. This way creating a PumpStreamHandler will fail early as
+   opposed to some obscure errors later when closing streams or
+   finishing threads might fail.
+   Bugzilla Report 62148
+
 Changes from Ant 1.9.10 TO Ant 1.9.11
 =====================================
 

http://git-wip-us.apache.org/repos/asf/ant/blob/0d306932/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
----------------------------------------------------------------------
diff --git a/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java 
b/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
index 31671fc..9f8484e 100644
--- a/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
+++ b/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
@@ -44,14 +44,20 @@ public class PumpStreamHandler implements 
ExecuteStreamHandler {
 
     /**
      * Construct a new <code>PumpStreamHandler</code>.
-     * @param out the output <code>OutputStream</code>.
-     * @param err the error <code>OutputStream</code>.
+     * @param out the output <code>OutputStream</code>, must not be null.
+     * @param err the error <code>OutputStream</code>, must not be null.
      * @param input the input <code>InputStream</code>.
      * @param nonBlockingRead set it to <code>true</code> if the input should 
be
      *                      read with simulated non blocking IO.
      */
     public PumpStreamHandler(OutputStream out, OutputStream err,
                              InputStream input, boolean nonBlockingRead) {
+        if (out == null) {
+            throw new NullPointerException("out must not be null");
+        }
+        if (err == null) {
+            throw new NullPointerException("err must not be null");
+        }
         this.out = out;
         this.err = err;
         this.input = input;
@@ -60,8 +66,8 @@ public class PumpStreamHandler implements 
ExecuteStreamHandler {
 
     /**
      * Construct a new <code>PumpStreamHandler</code>.
-     * @param out the output <code>OutputStream</code>.
-     * @param err the error <code>OutputStream</code>.
+     * @param out the output <code>OutputStream</code>, must not be null.
+     * @param err the error <code>OutputStream</code>, must not be null.
      * @param input the input <code>InputStream</code>.
      */
     public PumpStreamHandler(OutputStream out, OutputStream err,
@@ -71,8 +77,8 @@ public class PumpStreamHandler implements 
ExecuteStreamHandler {
 
     /**
      * Construct a new <code>PumpStreamHandler</code>.
-     * @param out the output <code>OutputStream</code>.
-     * @param err the error <code>OutputStream</code>.
+     * @param out the output <code>OutputStream</code>, must not be null.
+     * @param err the error <code>OutputStream</code>, must not be null.
      */
     public PumpStreamHandler(OutputStream out, OutputStream err) {
         this(out, err, null);
@@ -80,7 +86,7 @@ public class PumpStreamHandler implements 
ExecuteStreamHandler {
 
     /**
      * Construct a new <code>PumpStreamHandler</code>.
-     * @param outAndErr the output/error <code>OutputStream</code>.
+     * @param outAndErr the output/error <code>OutputStream</code>, must not 
be null.
      */
     public PumpStreamHandler(OutputStream outAndErr) {
         this(outAndErr, outAndErr);
@@ -108,9 +114,7 @@ public class PumpStreamHandler implements 
ExecuteStreamHandler {
      * @param is the <code>InputStream</code>.
      */
     public void setProcessErrorStream(InputStream is) {
-        if (err != null) {
-            createProcessErrorPump(is, err);
-        }
+        createProcessErrorPump(is, err);
     }
 
     /**

Reply via email to