diff --git a/WHATSNEW b/WHATSNEW index ac34cb08b..3cd29d516 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -278,6 +278,10 @@ Fixed bugs: some setups. Bugzilla Report 46063. + * if an error occurs while logging the buildFinished event, the + original error is now logged to System.err. + Bugzilla Report 25086. + Other changes: -------------- diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java index 5a53f4052..97a1e9046 100644 --- a/src/main/org/apache/tools/ant/Main.java +++ b/src/main/org/apache/tools/ant/Main.java @@ -792,7 +792,21 @@ public class Main implements AntMain { throw e; } finally { if (!projectHelp) { - project.fireBuildFinished(error); + try { + project.fireBuildFinished(error); + } catch (Throwable t) { + // yes, I know it is bad style to catch Throwable, + // but if we don't, we lose valuable information + System.err.println("Caught an exception while logging the" + + " end of the build. Exception was:"); + t.printStackTrace(); + if (error != null) { + System.err.println("There has been an error prior to" + + " that:"); + error.printStackTrace(); + } + throw new BuildException(t); + } } else if (error != null) { project.log(error.toString(), Project.MSG_ERR); }