db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Youngho Cho (JIRA)" <j...@apache.org>
Subject [jira] [Created] (TORQUE-300) AbstractBaseManager.getOMs method has a bug
Date Mon, 26 Aug 2013 05:02:51 GMT
Youngho Cho created TORQUE-300:
----------------------------------

             Summary: AbstractBaseManager.getOMs method has a bug
                 Key: TORQUE-300
                 URL: https://issues.apache.org/jira/browse/TORQUE-300
             Project: Torque
          Issue Type: Bug
          Components: Runtime
    Affects Versions: 4.0, 3.3
            Reporter: Youngho Cho
            Priority: Minor


AbstractBaseManager.getOMs method returns null when input ids is empty list.

I think this behavior is a bug.
If input ids list is null than returns null is ok
But if input ids list is not null but empty list than it should not return null but return
empty list.

Here is a patch against 3.3


@@ -21,6 +21,7 @@ package org.apache.torque.manager;
 
 import java.lang.ref.WeakReference;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.List;
 import java.util.ArrayList;
 import java.util.Map;
@@ -376,11 +377,16 @@ public abstract class AbstractBaseManager
     protected List getOMs(List ids, boolean fromCache)
         throws TorqueException
     {
-        List oms = null;
-        if (ids != null && ids.size() > 0)
+        if(ids == null)
         {
-            // start a new list where we will replace the id's with om's
-            oms = new ArrayList(ids);
+            return null;
+        }
+        if(ids.isEmpty())
+        {
+            return Collections.EMPTY_LIST;            
+        }
+        // start a new list where we will replace the id's with om's
+        List oms = new ArrayList(ids);
             List newIds = new ArrayList(ids.size());
             for (int i = 0; i < ids.size(); i++)
             {
@@ -426,7 +432,6 @@ public abstract class AbstractBaseManager
                     }
                 }
             }
-        }
         return oms;
     }



--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

---------------------------------------------------------------------
To unsubscribe, e-mail: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message