Browse Source

making the exec task fast again, using the patch provided by Tim Whittington, Bugzilla PR 54128

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1551113 13f79535-47bb-0310-9956-ffa450edef68
master
Antoine Levy-Lambert 11 years ago
parent
commit
e505c281d0
5 changed files with 27 additions and 3 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +3
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
  5. +18
    -2
      src/main/org/apache/tools/ant/taskdefs/StreamPumper.java

+ 1
- 0
CONTRIBUTORS View File

@@ -358,6 +358,7 @@ Thomas Quas
Tim Drury Tim Drury
Tim Fennell Tim Fennell
Tim Stephenson Tim Stephenson
Tim Whittington
Timoteo Ohara Timoteo Ohara
Timothy Gerard Endres Timothy Gerard Endres
Tom Ball Tom Ball


+ 3
- 0
WHATSNEW View File

@@ -22,6 +22,9 @@ Fixed bugs:
made macrodef fail. made macrodef fail.
Bugzilla Report 55885. Bugzilla Report 55885.


* Ant 1.8 exec task changes have slowed exec to a crawl
Bugzilla Report 54128.

Other changes: Other changes:
-------------- --------------




+ 4
- 0
contributors.xml View File

@@ -1435,6 +1435,10 @@
<first>Tim</first> <first>Tim</first>
<last>Fennell</last> <last>Fennell</last>
</name> </name>
<name>
<first>Tim</first>
<last>Whittington</last>
</name>
<name> <name>
<first>Timoteo</first> <first>Timoteo</first>
<last>Ohara</last> <last>Ohara</last>


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

@@ -185,10 +185,10 @@ public class PumpStreamHandler implements ExecuteStreamHandler {
return; return;
} }


t.join(JOIN_TIMEOUT);
if (s != null && !s.isFinished()) { if (s != null && !s.isFinished()) {
s.stop(); s.stop();
} }
t.join(JOIN_TIMEOUT);
while ((s == null || !s.isFinished()) && t.isAlive()) { while ((s == null || !s.isFinished()) && t.isAlive()) {
t.interrupt(); t.interrupt();
t.join(JOIN_TIMEOUT); t.join(JOIN_TIMEOUT);


+ 18
- 2
src/main/org/apache/tools/ant/taskdefs/StreamPumper.java View File

@@ -116,7 +116,6 @@ public class StreamPumper implements Runnable {
started = true; started = true;
} }
finished = false; finished = false;
finish = false;


final byte[] buf = new byte[bufferSize]; final byte[] buf = new byte[bufferSize];


@@ -130,13 +129,29 @@ public class StreamPumper implements Runnable {
} }


length = is.read(buf); length = is.read(buf);
if (length <= 0 || finish || Thread.interrupted()) {
if (length <= 0 || Thread.interrupted()) {
break; break;
} }
os.write(buf, 0, length); os.write(buf, 0, length);
if (autoflush) { if (autoflush) {
os.flush(); os.flush();
} }
if (finish) {
break;
}
}
// On completion, drain any available data (which might be the first data available for quick executions)
if (finish) {
while((length = is.available()) > 0) {
if (Thread.interrupted()) {
break;
}
length = is.read(buf, 0, Math.min(length, buf.length));
if (length <= 0) {
break;
}
os.write(buf, 0, length);
}
} }
os.flush(); os.flush();
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
@@ -150,6 +165,7 @@ public class StreamPumper implements Runnable {
FileUtils.close(os); FileUtils.close(os);
} }
finished = true; finished = true;
finish = false;
synchronized (this) { synchronized (this) {
notifyAll(); notifyAll();
} }


Loading…
Cancel
Save