Browse Source

speed up fast executions (where the process finishes in way less than a second) like attrib. PR 48734

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@927753 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 15 years ago
parent
commit
a5ffa2e18d
3 changed files with 55 additions and 2 deletions
  1. +9
    -0
      WHATSNEW
  2. +9
    -2
      src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
  3. +37
    -0
      src/tests/antunit/taskdefs/exec/exec-test.xml

+ 9
- 0
WHATSNEW View File

@@ -107,6 +107,15 @@ Other changes:
used to manifest itself in unrelated errors like
Bugzilla Report 43586.

* A change that made <exec> more reliable on Windows (Bugzilla Report
5003) strongly impacts the performance for commands that execute
quickly, like attrib. Basically no single execution of a command
could take less than a second on Windows.
A few timeouts have been tweaked to allow these commands to finish
more quickly but still they will take longer than they did with Ant
1.7.1.
Bugzilla Report 48734.

Changes from Ant 1.8.0RC1 TO Ant 1.8.0
======================================



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

@@ -148,7 +148,7 @@ public class PumpStreamHandler implements ExecuteStreamHandler {
finish(errorThread);
}

private static final long JOIN_TIMEOUT = 500;
private static final long JOIN_TIMEOUT = 200;

/**
* Waits for a thread to finish while trying to make it finish
@@ -160,11 +160,18 @@ public class PumpStreamHandler implements ExecuteStreamHandler {
*/
protected final void finish(Thread t) {
try {
t.join(JOIN_TIMEOUT);
StreamPumper s = null;
if (t instanceof ThreadWithPumper) {
s = ((ThreadWithPumper) t).getPumper();
}
if (s != null && s.isFinished()) {
return;
}
if (!t.isAlive()) {
return;
}

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


+ 37
- 0
src/tests/antunit/taskdefs/exec/exec-test.xml View File

@@ -628,4 +628,41 @@
</exec>
</target>
<target name="testDoesntWaitForChildren"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=5003">
<mkdir dir="${input}/org/example"/>
<pathconvert dirsep="/" property="out">
<path location="${output}"/>
</pathconvert>
<echo file="${input}/org/example/CallHello.java"><![CDATA[
package org.example;
public class CallHello {
public static void main(String[] args)
throws Exception {
Runtime.getRuntime().exec("java -cp ${out} org.example.Hello");
Thread.sleep(1 * 1000);
System.out.println("finished");
}
}]]></echo>
<echo file="${input}/org/example/Hello.java"><![CDATA[
package org.example;
public class Hello {
public static void main(String[] args)
throws Exception {
for (int i = 0; i < 20; ++i) {
System.out.println("Hello " + i);
System.out.flush();
Thread.sleep(1 * 1000);
}
}
}]]></echo>
<mkdir dir="${output}"/>
<javac srcdir="${input}" destdir="${output}"/>
<exec executable="java">
<arg line="-cp ${output} org.example.CallHello"/>
</exec>
<au:assertLogContains text="finished"/>
<au:assertLogDoesntContain text="Hello 20"/>
</target>

</project>

Loading…
Cancel
Save