Author: bodewig
Date: Fri Mar 26 09:59:20 2010
New Revision: 927753
URL: http://svn.apache.org/viewvc?rev=927753&view=rev
Log:
speed up fast executions (where the process finishes in way less than a second)
like attrib. PR 48734
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
ant/core/trunk/src/tests/antunit/taskdefs/exec/exec-test.xml
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=927753&r1=927752&r2=927753&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Mar 26 09:59:20 2010
@@ -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
======================================
Modified:
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java?rev=927753&r1=927752&r2=927753&view=diff
==============================================================================
---
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
(original)
+++
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java
Fri Mar 26 09:59:20 2010
@@ -148,7 +148,7 @@ public class PumpStreamHandler implement
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 implement
*/
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();
}
Modified: ant/core/trunk/src/tests/antunit/taskdefs/exec/exec-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/taskdefs/exec/exec-test.xml?rev=927753&r1=927752&r2=927753&view=diff
==============================================================================
--- ant/core/trunk/src/tests/antunit/taskdefs/exec/exec-test.xml (original)
+++ ant/core/trunk/src/tests/antunit/taskdefs/exec/exec-test.xml Fri Mar 26
09:59:20 2010
@@ -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>