From cb52a5011563fdb319e93994ab224e2184e7389a Mon Sep 17 00:00:00 2001 From: Matthew Jason Benson Date: Thu, 6 Oct 2005 18:45:32 +0000 Subject: [PATCH] add exception accessor per TODO git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@306835 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tools/ant/taskdefs/StreamPumper.java | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/StreamPumper.java b/src/main/org/apache/tools/ant/taskdefs/StreamPumper.java index 904a127e1..b52eabb8b 100644 --- a/src/main/org/apache/tools/ant/taskdefs/StreamPumper.java +++ b/src/main/org/apache/tools/ant/taskdefs/StreamPumper.java @@ -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