Browse Source

add exception accessor per TODO

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@306835 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 20 years ago
parent
commit
cb52a50115
1 changed files with 13 additions and 3 deletions
  1. +13
    -3
      src/main/org/apache/tools/ant/taskdefs/StreamPumper.java

+ 13
- 3
src/main/org/apache/tools/ant/taskdefs/StreamPumper.java View File

@@ -1,5 +1,5 @@
/*
* Copyright 2000,2002-2005 The Apache Software Foundation
* Copyright 2000, 2002-2005 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,6 @@ import java.io.OutputStream;
public class StreamPumper implements Runnable {

// TODO: make SIZE an instance variable.
// TODO: add a status flag to note if an error occurred in run.

private static final int SIZE = 128;
private InputStream is;
@@ -38,6 +37,7 @@ public class StreamPumper implements Runnable {
private volatile boolean finished;
private boolean closeWhenExhausted;
private boolean autoflush = false;
private Exception exception = null;

/**
* Create a new stream pumper.
@@ -94,7 +94,9 @@ public class StreamPumper implements Runnable {
}
os.flush();
} catch (Exception e) {
// ignore errors
synchronized (this) {
exception = e;
}
} finally {
if (closeWhenExhausted) {
try {
@@ -129,6 +131,14 @@ public class StreamPumper implements Runnable {
}
}

/**
* Get the exception encountered, if any.
* @return the Exception encountered.
*/
public synchronized Exception getException() {
return exception;
}

/**
* Stop the pumper as soon as possible.
* Note that it may continue to block on the input stream


Loading…
Cancel
Save