Description
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
{ @@ -426,7 +432,6 @@ public abstract class AbstractBaseManager }
+ List oms = new ArrayList(ids);
List newIds = new ArrayList(ids.size());
for (int i = 0; i < ids.size(); i++)}
} - }
return oms;
}