From fbd5fe56fc0976d47bac32bce811fa813e444794 Mon Sep 17 00:00:00 2001 From: "Jesse N. Glick" Date: Tue, 17 Nov 2009 23:56:21 +0000 Subject: [PATCH] Fixing fix for OOME in . Was getting wrapped in BuildException by both DispatchUtils.execute and Project.executeSortedTargets. Instead of trying to prevent wrapping, which is difficult to enforce, just die on wrapped hard errors. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@881627 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/tools/ant/taskdefs/SubAnt.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/org/apache/tools/ant/taskdefs/SubAnt.java b/src/main/org/apache/tools/ant/taskdefs/SubAnt.java index 5d336e209..56ebedab0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SubAnt.java +++ b/src/main/org/apache/tools/ant/taskdefs/SubAnt.java @@ -301,18 +301,14 @@ public class SubAnt extends Task { try { ant.execute(); } catch (BuildException e) { - if (failOnError) { + if (failOnError || isHardError(e)) { throw e; } log("Failure for target '" + subTarget + "' of: " + antfilename + "\n" + e.getMessage(), Project.MSG_WARN); - } catch (OutOfMemoryError e) { - throw e; - } catch (ThreadDeath e) { - throw e; } catch (Throwable e) { - if (failOnError) { + if (failOnError || isHardError(e)) { throw new BuildException(e); } log("Failure for target '" + subTarget @@ -323,6 +319,18 @@ public class SubAnt extends Task { ant = null; } } + /** whether we should even try to continue after this error */ + private boolean isHardError(Throwable t) { + if (t instanceof BuildException) { + return isHardError(t.getCause()); + } else if (t instanceof OutOfMemoryError) { + return true; + } else if (t instanceof ThreadDeath) { + return true; + } else { // incl. t == null + return false; + } + } /** * This method builds the file name to use in conjunction with directories.