diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 9ca02b14a..c760814ca 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -52,6 +52,7 @@ Dan Armbrust Daniel Ribagnac Daniel Spilker Danno Ferrin +Dante Briones Davanum Srinivas Dave Brondsema Dave Brosius diff --git a/WHATSNEW b/WHATSNEW index e36978588..38177f62e 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -44,6 +44,11 @@ Changes that could break older environments: simultaniously (while within , for example). This lock is no longer in place, messageLogged should be made thread-safe now. + * 's onError="stop" no longer fails the build if an error + occurs, this is the main difference between stop and error and + matches what the documentation implied. + Bugzilla Report 24668. + Fixed bugs: ----------- diff --git a/contributors.xml b/contributors.xml index 7459e64b2..294765863 100644 --- a/contributors.xml +++ b/contributors.xml @@ -231,6 +231,10 @@ Danno Ferrin + + Dante + Briones + Davanum Srinivas diff --git a/docs/manual/CoreTasks/sql.html b/docs/manual/CoreTasks/sql.html index f70c426e3..b348c63c8 100644 --- a/docs/manual/CoreTasks/sql.html +++ b/docs/manual/CoreTasks/sql.html @@ -40,7 +40,7 @@ statements will all be executed as one transaction.

The onerror attribute specifies how to proceed when an error occurs during the execution of one of the statements. The possible values are: continue execution, only show the error; -stop execution and commit transaction; +stop execution, log the error but don't fail the task and abort execution and transaction and fail task.

diff --git a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java index 4a0ac32e0..708fbe34f 100644 --- a/src/main/org/apache/tools/ant/taskdefs/SQLExec.java +++ b/src/main/org/apache/tools/ant/taskdefs/SQLExec.java @@ -466,10 +466,14 @@ public class SQLExec extends JDBCTask { } } catch (IOException e) { closeQuietly(); - throw new BuildException(e, getLocation()); + if (onError.equals("abort")) { + throw new BuildException(e, getLocation()); + } } catch (SQLException e) { closeQuietly(); - throw new BuildException(e, getLocation()); + if (onError.equals("abort")) { + throw new BuildException(e, getLocation()); + } } finally { try { if (statement != null) { @@ -603,10 +607,12 @@ public class SQLExec extends JDBCTask { goodSql++; } catch (SQLException e) { log("Failed to execute: " + sql, Project.MSG_ERR); + if (!onError.equals("abort")) { + log(e.toString(), Project.MSG_ERR); + } if (!onError.equals("continue")) { throw e; } - log(e.toString(), Project.MSG_ERR); } finally { if (resultSet != null) { try {