bodewig 2004/03/15 03:23:48 Modified: . WHATSNEW docs faq.html src/main/org/apache/tools/ant/taskdefs Java.java xdocs faq.xml Log: Don't swallow the stack trace if a Java program throws an exception. Revision Changes Path 1.572 +3 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.571 retrieving revision 1.572 diff -u -r1.571 -r1.572 --- WHATSNEW 12 Mar 2004 09:00:30 -0000 1.571 +++ WHATSNEW 15 Mar 2004 11:23:47 -0000 1.572 @@ -84,6 +84,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: -------------- 1.95 +18 -0 ant/docs/faq.html Index: faq.html =================================================================== RCS file: /home/cvs/ant/docs/faq.html,v retrieving revision 1.94 retrieving revision 1.95 diff -u -r1.94 -r1.95 --- faq.html 29 Feb 2004 08:43:54 -0000 1.94 +++ faq.html 15 Mar 2004 11:23:48 -0000 1.95 @@ -342,6 +342,12 @@ - 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> </ul> <h3 class="section">Answers</h3> @@ -1593,6 +1599,18 @@ <p> This approach should work for ant1.5 and ant1.6. </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> 1.87 +14 -2 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.86 retrieving revision 1.87 diff -u -r1.86 -r1.87 --- Java.java 9 Mar 2004 16:48:05 -0000 1.86 +++ Java.java 15 Mar 2004 11:23:48 -0000 1.87 @@ -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; } } @@ -792,4 +794,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); + } } 1.51 +15 -0 ant/xdocs/faq.xml Index: faq.xml =================================================================== RCS file: /home/cvs/ant/xdocs/faq.xml,v retrieving revision 1.50 retrieving revision 1.51 diff -u -r1.50 -r1.51 --- faq.xml 19 Feb 2004 12:45:03 -0000 1.50 +++ faq.xml 15 Mar 2004 11:23:48 -0000 1.51 @@ -1409,6 +1409,21 @@ </p> </answer> </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> </document>
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]