bodewig 2004/03/15 03:29:13
Modified: . Tag: ANT_16_BRANCH WHATSNEW
src/main/org/apache/tools/ant/taskdefs Tag: ANT_16_BRANCH
Java.java
Log:
merge
Revision Changes Path
No revision
No revision
1.503.2.60 +3 -0 ant/WHATSNEW
Index: WHATSNEW
===================================================================
RCS file: /home/cvs/ant/WHATSNEW,v
retrieving revision 1.503.2.59
retrieving revision 1.503.2.60
diff -u -r1.503.2.59 -r1.503.2.60
--- WHATSNEW 12 Mar 2004 09:01:48 -0000 1.503.2.59
+++ WHATSNEW 15 Mar 2004 11:29:13 -0000 1.503.2.60
@@ -35,6 +35,9 @@
* NPE when running commons listener. Bugzilla Report 27373.
+* <java> swallowed the stack trace of exceptions thrown by the
+ executed program if run in the same VM.
+
Other changes:
--------------
No revision
No revision
1.77.2.8 +74 -62 ant/src/main/org/apache/tools/ant/taskdefs/Java.java
Index: Java.java
===================================================================
RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v
retrieving revision 1.77.2.7
retrieving revision 1.77.2.8
diff -u -r1.77.2.7 -r1.77.2.8
--- Java.java 9 Mar 2004 17:01:33 -0000 1.77.2.7
+++ Java.java 15 Mar 2004 11:29:13 -0000 1.77.2.8
@@ -19,6 +19,8 @@
import java.io.File;
import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
import java.util.Vector;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.ExitException;
@@ -169,14 +171,14 @@
if (failOnError) {
throw e;
} else {
- log(e.getMessage(), Project.MSG_ERR);
+ log(e);
return 0;
}
} catch (Throwable t) {
if (failOnError) {
throw new BuildException(t);
} else {
- log(t.getMessage(), Project.MSG_ERR);
+ log(t);
return 0;
}
}
@@ -667,41 +669,41 @@
*/
private int fork(String[] command) throws BuildException {
- Execute exe
- = new Execute(redirector.createHandler(), createWatchdog());
- exe.setAntRun(getProject());
-
- if (dir == null) {
- dir = getProject().getBaseDir();
- } else if (!dir.exists() || !dir.isDirectory()) {
- throw new BuildException(dir.getAbsolutePath()
- + " is not a valid directory",
- getLocation());
- }
-
- exe.setWorkingDirectory(dir);
-
- String[] environment = env.getVariables();
- if (environment != null) {
- for (int i = 0; i < environment.length; i++) {
- log("Setting environment variable: " + environment[i],
- Project.MSG_VERBOSE);
- }
+ Execute exe
+ = new Execute(redirector.createHandler(), createWatchdog());
+ exe.setAntRun(getProject());
+
+ if (dir == null) {
+ dir = getProject().getBaseDir();
+ } else if (!dir.exists() || !dir.isDirectory()) {
+ throw new BuildException(dir.getAbsolutePath()
+ + " is not a valid directory",
+ getLocation());
+ }
+
+ exe.setWorkingDirectory(dir);
+
+ String[] environment = env.getVariables();
+ if (environment != null) {
+ for (int i = 0; i < environment.length; i++) {
+ log("Setting environment variable: " + environment[i],
+ Project.MSG_VERBOSE);
}
- exe.setNewenvironment(newEnvironment);
- exe.setEnvironment(environment);
+ }
+ exe.setNewenvironment(newEnvironment);
+ exe.setEnvironment(environment);
- exe.setCommandline(command);
- try {
- int rc = exe.execute();
- redirector.complete();
- if (exe.killedProcess()) {
- throw new BuildException("Timeout: killed the
sub-process");
- }
- return rc;
- } catch (IOException e) {
- throw new BuildException(e, getLocation());
+ exe.setCommandline(command);
+ try {
+ int rc = exe.execute();
+ redirector.complete();
+ if (exe.killedProcess()) {
+ throw new BuildException("Timeout: killed the sub-process");
}
+ return rc;
+ } catch (IOException e) {
+ throw new BuildException(e, getLocation());
+ }
}
/**
@@ -709,36 +711,36 @@
*/
private void spawn(String[] command) throws BuildException {
- Execute exe
- = new Execute();
- exe.setAntRun(getProject());
-
- if (dir == null) {
- dir = getProject().getBaseDir();
- } else if (!dir.exists() || !dir.isDirectory()) {
- throw new BuildException(dir.getAbsolutePath()
- + " is not a valid directory",
- getLocation());
- }
-
- exe.setWorkingDirectory(dir);
-
- String[] environment = env.getVariables();
- if (environment != null) {
- for (int i = 0; i < environment.length; i++) {
- log("Setting environment variable: " + environment[i],
- Project.MSG_VERBOSE);
- }
- }
- exe.setNewenvironment(newEnvironment);
- exe.setEnvironment(environment);
+ Execute exe
+ = new Execute();
+ exe.setAntRun(getProject());
+
+ if (dir == null) {
+ dir = getProject().getBaseDir();
+ } else if (!dir.exists() || !dir.isDirectory()) {
+ throw new BuildException(dir.getAbsolutePath()
+ + " is not a valid directory",
+ getLocation());
+ }
- exe.setCommandline(command);
- try {
- exe.spawn();
- } catch (IOException e) {
- throw new BuildException(e, getLocation());
+ exe.setWorkingDirectory(dir);
+
+ String[] environment = env.getVariables();
+ if (environment != null) {
+ for (int i = 0; i < environment.length; i++) {
+ log("Setting environment variable: " + environment[i],
+ Project.MSG_VERBOSE);
}
+ }
+ exe.setNewenvironment(newEnvironment);
+ exe.setEnvironment(environment);
+
+ exe.setCommandline(command);
+ try {
+ exe.spawn();
+ } catch (IOException e) {
+ throw new BuildException(e, getLocation());
+ }
}
/**
* Executes the given classname with the given arguments as it
@@ -780,4 +782,14 @@
return new ExecuteWatchdog(timeout.longValue());
}
+ /**
+ * @since 1.6.2
+ */
+ private void log(Throwable t) {
+ StringWriter sw = new StringWriter();
+ PrintWriter w = new PrintWriter(sw);
+ t.printStackTrace(w);
+ w.close();
+ log(sw.toString(), Project.MSG_ERR);
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]