From a5ffa2e18d16de87b27b48e694911d2504a04835 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Fri, 26 Mar 2010 09:59:20 +0000 Subject: [PATCH] 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 --- WHATSNEW | 9 +++++ .../tools/ant/taskdefs/PumpStreamHandler.java | 11 +++++- src/tests/antunit/taskdefs/exec/exec-test.xml | 37 +++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 7eb1b949c..4e48b0368 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -107,6 +107,15 @@ Other changes: used to manifest itself in unrelated errors like Bugzilla Report 43586. + * A change that made 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 ====================================== diff --git a/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java b/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java index 1187ac175..573f40679 100644 --- a/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java +++ b/src/main/org/apache/tools/ant/taskdefs/PumpStreamHandler.java @@ -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(); } diff --git a/src/tests/antunit/taskdefs/exec/exec-test.xml b/src/tests/antunit/taskdefs/exec/exec-test.xml index c7202f9c4..84f66d3e2 100644 --- a/src/tests/antunit/taskdefs/exec/exec-test.xml +++ b/src/tests/antunit/taskdefs/exec/exec-test.xml @@ -628,4 +628,41 @@ + + + + + + + + + + + + + + + +