Author: bodewig
Date: Thu Jul 10 07:06:44 2008
New Revision: 675579
URL: http://svn.apache.org/viewvc?rev=675579&view=rev
Log:
sql's onerror='stop' shouldn't make the task fail. PR 24668. Based on a patch
by Dante Briones.
Modified:
ant/core/trunk/CONTRIBUTORS
ant/core/trunk/WHATSNEW
ant/core/trunk/contributors.xml
ant/core/trunk/docs/manual/CoreTasks/sql.html
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
Modified: ant/core/trunk/CONTRIBUTORS
URL:
http://svn.apache.org/viewvc/ant/core/trunk/CONTRIBUTORS?rev=675579&r1=675578&r2=675579&view=diff
==============================================================================
Binary files - no diff available.
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=675579&r1=675578&r2=675579&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Jul 10 07:06:44 2008
@@ -44,6 +44,11 @@
simultaniously (while within <parallel>, for example). This lock is
no longer in place, messageLogged should be made thread-safe now.
+ * <sql>'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:
-----------
Modified: ant/core/trunk/contributors.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/contributors.xml?rev=675579&r1=675578&r2=675579&view=diff
==============================================================================
--- ant/core/trunk/contributors.xml (original)
+++ ant/core/trunk/contributors.xml Thu Jul 10 07:06:44 2008
@@ -232,6 +232,10 @@
<last>Ferrin</last>
</name>
<name>
+ <first>Dante</first>
+ <last>Briones</last>
+ </name>
+ <name>
<first>Davanum</first>
<last>Srinivas</last>
</name>
Modified: ant/core/trunk/docs/manual/CoreTasks/sql.html
URL:
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/sql.html?rev=675579&r1=675578&r2=675579&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/sql.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/sql.html Thu Jul 10 07:06:44 2008
@@ -40,7 +40,7 @@
<p>The <i>onerror</i> attribute specifies how to proceed when an error occurs
during the execution of one of the statements.
The possible values are: <b>continue</b> execution, only show the error;
-<b>stop</b> execution and commit transaction;
+<b>stop</b> execution, log the error but don't fail the task
and <b>abort</b> execution and transaction and fail task.</p>
<p>
Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java?rev=675579&r1=675578&r2=675579&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
(original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java Thu Jul
10 07:06:44 2008
@@ -466,10 +466,14 @@
}
} 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 @@
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 {