Browse Source

properly verify preconditions in PumpStreamHandler

https://bz.apache.org/bugzilla/show_bug.cgi?id=62148
master
Stefan Bodewig 7 years ago
parent
commit
0d30693274
2 changed files with 24 additions and 10 deletions
  1. +10
    -0
      WHATSNEW
  2. +14
    -10
      src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java

+ 10
- 0
WHATSNEW View File

@@ -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
=====================================



+ 14
- 10
src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java View File

@@ -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);
}

/**


Loading…
Cancel
Save