ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r631430 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java
Date Tue, 26 Feb 2008 23:59:17 GMT
Author: mbenson
Date: Tue Feb 26 15:59:16 2008
New Revision: 631430

URL: http://svn.apache.org/viewvc?rev=631430&view=rev
Log:
bz 44493 <sql> task cannot differentiate between "no resources specified" and "no resources
found"

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/SQLExec.java

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=631430&r1=631429&r2=631430&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 Tue Feb 26 15:59:16
2008
@@ -103,7 +103,7 @@
     /**
      * files to load
      */
-    private Union resources = new Union();
+    private Union resources;
 
     /**
      * SQL statement
@@ -255,6 +255,14 @@
      * @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 @@
         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 @@
                         + " 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



Mime
View raw message