git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@276233 13f79535-47bb-0310-9956-ffa450edef68master
@@ -84,6 +84,9 @@ Fixed bugs: | |||||
* NPE when running commons listener. Bugzilla Report 27373. | * 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: | Other changes: | ||||
-------------- | -------------- | ||||
@@ -341,6 +341,12 @@ | |||||
Why do my custom task containers see Unknown Elements in Ant 1.6 | Why do my custom task containers see Unknown Elements in Ant 1.6 | ||||
- they worked in Ant 1.5? | - they worked in Ant 1.5? | ||||
</a></li> | |||||
<li><a href="#java.exception.stacktrace"> | |||||
The program I run via <java> throws an exception but I | |||||
can't seem to get the full stack trace. | |||||
</a></li> | </a></li> | ||||
</ul> | </ul> | ||||
@@ -1593,6 +1599,18 @@ mv /tmp/foo $ANT_HOME/bin/antRun | |||||
<p> | <p> | ||||
This approach should work for ant1.5 and ant1.6. | This approach should work for ant1.5 and ant1.6. | ||||
</p> | </p> | ||||
<p class="faq"> | |||||
<a name="java.exception.stacktrace"></a> | |||||
The program I run via <java> throws an exception but I | |||||
can't seem to get the full stack trace. | |||||
</p> | |||||
<p>This is a know bug that has been fixed after the release of | |||||
Ant 1.6.1.</p> | |||||
<p>As a workaround, run your <java> task with | |||||
<code>fork="true"</code> and Ant will display the full | |||||
trace.</p> | |||||
</div> | </div> | ||||
</div> | </div> | ||||
@@ -19,6 +19,8 @@ package org.apache.tools.ant.taskdefs; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.PrintWriter; | |||||
import java.io.StringWriter; | |||||
import java.util.Vector; | import java.util.Vector; | ||||
import org.apache.tools.ant.BuildException; | import org.apache.tools.ant.BuildException; | ||||
import org.apache.tools.ant.ExitException; | import org.apache.tools.ant.ExitException; | ||||
@@ -169,14 +171,14 @@ public class Java extends Task { | |||||
if (failOnError) { | if (failOnError) { | ||||
throw e; | throw e; | ||||
} else { | } else { | ||||
log(e.getMessage(), Project.MSG_ERR); | |||||
log(e); | |||||
return 0; | return 0; | ||||
} | } | ||||
} catch (Throwable t) { | } catch (Throwable t) { | ||||
if (failOnError) { | if (failOnError) { | ||||
throw new BuildException(t); | throw new BuildException(t); | ||||
} else { | } else { | ||||
log(t.getMessage(), Project.MSG_ERR); | |||||
log(t); | |||||
return 0; | return 0; | ||||
} | } | ||||
} | } | ||||
@@ -792,4 +794,14 @@ public class Java extends Task { | |||||
return new ExecuteWatchdog(timeout.longValue()); | 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); | |||||
} | |||||
} | } |
@@ -1409,6 +1409,21 @@ mv /tmp/foo $ANT_HOME/bin/antRun | |||||
</p> | </p> | ||||
</answer> | </answer> | ||||
</faq> | </faq> | ||||
<faq id="java.exception.stacktrace"> | |||||
<question> | |||||
The program I run via <java> throws an exception but I | |||||
can't seem to get the full stack trace. | |||||
</question> | |||||
<answer> | |||||
<p>This is a know bug that has been fixed after the release of | |||||
Ant 1.6.1.</p> | |||||
<p>As a workaround, run your <java> task with | |||||
<code>fork="true"</code> and Ant will display the full | |||||
trace.</p> | |||||
</answer> | |||||
</faq> | |||||
</faqsection> | </faqsection> | ||||
</document> | </document> |