Browse Source

make sure output of the spawned thread is attributed to the current

<java> task when using the timeout feature.

If you don't like the name of the method, change it 8-)


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@272245 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 23 years ago
parent
commit
4c560e713a
2 changed files with 15 additions and 0 deletions
  1. +14
    -0
      src/main/org/apache/tools/ant/Project.java
  2. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java

+ 14
- 0
src/main/org/apache/tools/ant/Project.java View File

@@ -1874,4 +1874,18 @@ public class Project {
BuildEvent event = new BuildEvent(task);
fireMessageLoggedEvent(event, message, priority);
}

/**
* Treat messages generated in the given thread as messages that
* come from the same task that is performed on the current
* thread.
*
* @since 1.102, Ant 1.5
*/
public void registerThreadLikeCurrent(Thread thread) {
Task task = (Task) threadTasks.get(Thread.currentThread());
if (task != null) {
threadTasks.put(thread, task);
}
}
}

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

@@ -139,6 +139,7 @@ public class ExecuteJava implements Runnable, TimeoutObserver {
run();
} else {
thread = new Thread(this, "ExecuteJava");
project.registerThreadLikeCurrent(thread);
// if we run into a timout, the run-away thread shall not
// make the VM run forever - if no timeout occurs, Ant's
// main thread will still be there to let the new thread


Loading…
Cancel
Save