Browse Source

bz 44493 <sql> task cannot differentiate between "no resources specified" and "no resources found"

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@631430 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 17 years ago
parent
commit
82372e064b
1 changed files with 19 additions and 10 deletions
  1. +19
    -10
      src/main/org/apache/tools/ant/taskdefs/SQLExec.java

+ 19
- 10
src/main/org/apache/tools/ant/taskdefs/SQLExec.java View File

@@ -103,7 +103,7 @@ public class SQLExec extends JDBCTask {
/**
* files to load
*/
private Union resources = new Union();
private Union resources;

/**
* SQL statement
@@ -255,6 +255,14 @@ public class SQLExec extends JDBCTask {
* @since Ant 1.7
*/
public void add(ResourceCollection rc) {
if (rc == null) {
throw new BuildException("Cannot add null ResourceCollection");
}
synchronized (this) {
if (resources == null) {
resources = new Union();
}
}
resources.add(rc);
}

@@ -399,8 +407,7 @@ public class SQLExec extends JDBCTask {
sqlCommand = sqlCommand.trim();

try {
if (srcFile == null && sqlCommand.length() == 0
&& resources.size() == 0) {
if (srcFile == null && sqlCommand.length() == 0 && resources == null) {
if (transactions.size() == 0) {
throw new BuildException("Source file or resource collection, "
+ "transactions or sql statement "
@@ -413,13 +420,15 @@ public class SQLExec extends JDBCTask {
+ " is not a file!", getLocation());
}

// deal with the resources
Iterator iter = resources.iterator();
while (iter.hasNext()) {
Resource r = (Resource) iter.next();
// Make a transaction for each resource
Transaction t = createTransaction();
t.setSrcResource(r);
if (resources != null) {
// deal with the resources
Iterator iter = resources.iterator();
while (iter.hasNext()) {
Resource r = (Resource) iter.next();
// Make a transaction for each resource
Transaction t = createTransaction();
t.setSrcResource(r);
}
}

// Make a transaction group for the outer command


Loading…
Cancel
Save