Uploaded image for project: 'Torque'
  1. Torque
  2. TORQUE-300

AbstractBaseManager.getOMs method has a bug

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.3, 4.0
    • 5.0
    • Runtime

    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
        + 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;
        }

      Attachments

        Activity

          People

            tfischer Thomas Fox
            youngho Youngho Cho
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: