Browse Source

sql's onerror='stop' shouldn't make the task fail. PR 24668. Based on a patch by Dante Briones.

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@675579 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 17 years ago
parent
commit
02b3a7d13c
5 changed files with 20 additions and 4 deletions
  1. +1
    -0
      CONTRIBUTORS
  2. +5
    -0
      WHATSNEW
  3. +4
    -0
      contributors.xml
  4. +1
    -1
      docs/manual/CoreTasks/sql.html
  5. +9
    -3
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java

+ 1
- 0
CONTRIBUTORS View File

@@ -52,6 +52,7 @@ Dan Armbrust
Daniel Ribagnac
Daniel Spilker
Danno Ferrin
Dante Briones
Davanum Srinivas
Dave Brondsema
Dave Brosius


+ 5
- 0
WHATSNEW View File

@@ -44,6 +44,11 @@ Changes that could break older environments:
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:
-----------



+ 4
- 0
contributors.xml View File

@@ -231,6 +231,10 @@
<first>Danno</first>
<last>Ferrin</last>
</name>
<name>
<first>Dante</first>
<last>Briones</last>
</name>
<name>
<first>Davanum</first>
<last>Srinivas</last>


+ 1
- 1
docs/manual/CoreTasks/sql.html View File

@@ -40,7 +40,7 @@ statements will all be executed as one transaction.</p>
<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>


+ 9
- 3
src/main/org/apache/tools/ant/taskdefs/SQLExec.java View File

@@ -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 {


Loading…
Cancel
Save