You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-dev@db.apache.org by tf...@apache.org on 2013/08/30 03:20:07 UTC

svn commit: r1518873 - in /db/torque/torque4/trunk: torque-runtime/src/main/java/org/apache/torque/manager/AbstractBaseManager.java torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java

Author: tfischer
Date: Fri Aug 30 01:20:07 2013
New Revision: 1518873

URL: http://svn.apache.org/r1518873
Log:
- TORQUE-300 never return null in getOMs()
- add final modifiers to method parameters

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/AbstractBaseManager.java
    db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/AbstractBaseManager.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/AbstractBaseManager.java?rev=1518873&r1=1518872&r2=1518873&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/AbstractBaseManager.java (original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/AbstractBaseManager.java Fri Aug 30 01:20:07 2013
@@ -98,7 +98,7 @@ public abstract class AbstractBaseManage
      *
      * @param omClass the om class
      */
-    protected void setOMClass(Class<T> omClass)
+    protected void setOMClass(final Class<T> omClass)
     {
         this.omClass = omClass;
     }
@@ -144,7 +144,7 @@ public abstract class AbstractBaseManage
      *         rethrown wrapped into a TorqueException.
      */
     @SuppressWarnings("unchecked")
-    public void setClassName(String v)
+    public void setClassName(final String v)
         throws TorqueException
     {
         this.className = v;
@@ -178,7 +178,7 @@ public abstract class AbstractBaseManage
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    protected T getOMInstance(ObjectKey id)
+    protected T getOMInstance(final ObjectKey id)
         throws TorqueException
     {
         return getOMInstance(id, true);
@@ -193,7 +193,7 @@ public abstract class AbstractBaseManage
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    protected T getOMInstance(ObjectKey key, boolean fromCache)
+    protected T getOMInstance(final ObjectKey key, final boolean fromCache)
         throws TorqueException
     {
         T om = null;
@@ -221,7 +221,7 @@ public abstract class AbstractBaseManage
      * @return the object from cache
      */
     @SuppressWarnings("unchecked")
-    protected T cacheGet(Serializable key)
+    protected T cacheGet(final Serializable key)
     {
         T om = null;
         if (cache != null)
@@ -280,7 +280,7 @@ public abstract class AbstractBaseManage
      *         rethrown wrapped into a TorqueException.
      */
     @SuppressWarnings("unchecked")
-    protected T removeInstanceImpl(Serializable key)
+    protected T removeInstanceImpl(final Serializable key)
         throws TorqueException
     {
         T oldOm = null;
@@ -313,7 +313,7 @@ public abstract class AbstractBaseManage
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    protected T putInstanceImpl(T om)
+    protected T putInstanceImpl(final T om)
         throws TorqueException
     {
         ObjectKey key = om.getPrimaryKey();
@@ -331,7 +331,7 @@ public abstract class AbstractBaseManage
      *         rethrown wrapped into a TorqueException.
      */
     @SuppressWarnings("unchecked")
-    protected T putInstanceImpl(Serializable key, T om)
+    protected T putInstanceImpl(final Serializable key, final T om)
         throws TorqueException
     {
         if (getOMClass() != null && !getOMClass().isInstance(om))
@@ -380,7 +380,7 @@ public abstract class AbstractBaseManage
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    protected List<T> getOMs(ObjectKey[] ids)
+    protected List<T> getOMs(final ObjectKey[] ids)
         throws TorqueException
     {
         return getOMs(Arrays.asList(ids));
@@ -394,7 +394,7 @@ public abstract class AbstractBaseManage
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    protected List<T> getOMs(List<? extends ObjectKey>  ids)
+    protected List<T> getOMs(final List<? extends ObjectKey>  ids)
         throws TorqueException
     {
         return getOMs(ids, true);
@@ -403,15 +403,19 @@ public abstract class AbstractBaseManage
     /**
      * Gets a list of om's based on id's.
      *
-     * @param ids a <code>List</code> of <code>ObjectKey</code>'s
-     * @return a <code>List</code> value
+     * @param ids a <code>List</code> of <code>ObjectKey</code>'s.
+     *
+     * @return a <code>List</code> value, not null.
+     *
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    protected List<T> getOMs(List<? extends ObjectKey> ids, boolean fromCache)
+    protected List<T> getOMs(
+            final List<? extends ObjectKey> ids,
+            final boolean fromCache)
         throws TorqueException
     {
-        List<T> oms = null;
+        List<T> oms = new ArrayList<T>();
         if (ids != null && ids.size() > 0)
         {
             // start a new list where we will replace the id's with om's
@@ -447,7 +451,6 @@ public abstract class AbstractBaseManage
                 }
             }
 
-            oms = new ArrayList<T>(ids.size());
             for (ObjectKey key : ids)
             {
                 oms.add(omsMap.get(key));
@@ -485,7 +488,7 @@ public abstract class AbstractBaseManage
      * @throws TorqueException Any exceptions caught during processing will be
      *         rethrown wrapped into a TorqueException.
      */
-    public void setRegion(String v)
+    public void setRegion(final String v)
         throws TorqueException
     {
         this.region = v;
@@ -538,7 +541,8 @@ public abstract class AbstractBaseManage
      *
      * @param listener A new listener for cache events.
      */
-    public void addCacheListenerImpl(CacheListener<? extends Persistent> listener)
+    public void addCacheListenerImpl(
+            final CacheListener<? extends Persistent> listener)
     {
         List<String> keys = listener.getInterestedFields();
         for (String key : keys)
@@ -585,7 +589,7 @@ public abstract class AbstractBaseManage
      * @param key
      * @return A subset of the list identified by <code>key</code>.
      */
-    private synchronized FastArrayList createSubsetList(String key)
+    private synchronized FastArrayList createSubsetList(final String key)
     {
         FastArrayList list = null;
         if (listenersMap.containsKey(key))
@@ -607,8 +611,10 @@ public abstract class AbstractBaseManage
      * @param oldOm
      * @param om
      */
-    protected <TT extends Persistent> void notifyListeners(List<WeakReference<CacheListener<TT>>> listeners,
-                                   TT oldOm, TT om)
+    protected <TT extends Persistent> void notifyListeners(
+            final List<WeakReference<CacheListener<TT>>> listeners,
+            final TT oldOm,
+            final TT om)
     {
         if (listeners != null)
         {
@@ -648,7 +654,7 @@ public abstract class AbstractBaseManage
      * @param out
      * @throws IOException
      */
-    private void writeObject(java.io.ObjectOutputStream out)
+    private void writeObject(final java.io.ObjectOutputStream out)
         throws IOException
     {
         out.defaultWriteObject();
@@ -661,7 +667,7 @@ public abstract class AbstractBaseManage
      * @throws IOException
      * @throws ClassNotFoundException
      */
-    private void readObject(ObjectInputStream in)
+    private void readObject(final ObjectInputStream in)
         throws IOException, ClassNotFoundException
     {
         in.defaultReadObject();

Modified: db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java?rev=1518873&r1=1518872&r2=1518873&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java (original)
+++ db/torque/torque4/trunk/torque-test/src/test/java/org/apache/torque/ManagerTestConditional.java Fri Aug 30 01:20:07 2013
@@ -107,7 +107,7 @@ public class ManagerTestConditional exte
     public void testGetInstancesNull() throws Exception
     {
         List<Author> authors = AuthorManager.getInstances(null);
-        assertNull(authors);
+        assertEquals(new ArrayList<Author>(), authors);
     }
 
     /**



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