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 Ribagnac
Daniel Spilker Daniel Spilker
Danno Ferrin Danno Ferrin
Dante Briones
Davanum Srinivas Davanum Srinivas
Dave Brondsema Dave Brondsema
Dave Brosius 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 simultaniously (while within <parallel>, for example). This lock is
no longer in place, messageLogged should be made thread-safe now. 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: Fixed bugs:
----------- -----------




+ 4
- 0
contributors.xml View File

@@ -231,6 +231,10 @@
<first>Danno</first> <first>Danno</first>
<last>Ferrin</last> <last>Ferrin</last>
</name> </name>
<name>
<first>Dante</first>
<last>Briones</last>
</name>
<name> <name>
<first>Davanum</first> <first>Davanum</first>
<last>Srinivas</last> <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 <p>The <i>onerror</i> attribute specifies how to proceed when an error occurs
during the execution of one of the statements. during the execution of one of the statements.
The possible values are: <b>continue</b> execution, only show the error; 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> and <b>abort</b> execution and transaction and fail task.</p>


<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) { } catch (IOException e) {
closeQuietly(); closeQuietly();
throw new BuildException(e, getLocation());
if (onError.equals("abort")) {
throw new BuildException(e, getLocation());
}
} catch (SQLException e) { } catch (SQLException e) {
closeQuietly(); closeQuietly();
throw new BuildException(e, getLocation());
if (onError.equals("abort")) {
throw new BuildException(e, getLocation());
}
} finally { } finally {
try { try {
if (statement != null) { if (statement != null) {
@@ -603,10 +607,12 @@ public class SQLExec extends JDBCTask {
goodSql++; goodSql++;
} catch (SQLException e) { } catch (SQLException e) {
log("Failed to execute: " + sql, Project.MSG_ERR); log("Failed to execute: " + sql, Project.MSG_ERR);
if (!onError.equals("abort")) {
log(e.toString(), Project.MSG_ERR);
}
if (!onError.equals("continue")) { if (!onError.equals("continue")) {
throw e; throw e;
} }
log(e.toString(), Project.MSG_ERR);
} finally { } finally {
if (resultSet != null) { if (resultSet != null) {
try { try {


Loading…
Cancel
Save