db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1838900 - in /db/torque/torque4/trunk/torque-runtime/src: main/java/org/apache/torque/ main/java/org/apache/torque/adapter/ main/java/org/apache/torque/criteria/ main/java/org/apache/torque/manager/ main/java/org/apache/torque/om/ main/jav...
Date Fri, 24 Aug 2018 16:44:52 GMT
Author: tv
Date: Fri Aug 24 16:44:52 2018
New Revision: 1838900

URL: http://svn.apache.org/viewvc?rev=1838900&view=rev
Log:
Fix Spotbugs findings

Modified:
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DerbyAdapter.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/manager/AbstractBaseManager.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/om/ComboKey.java
    db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/BaseTestCase.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriteriaTest.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/om/NumberKeyTest.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/om/mapper/CompositeMapperTest.java
    db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/SummaryHelperTest.java

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java?rev=1838900&r1=1838899&r2=1838900&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/TorqueInstance.java
Fri Aug 24 16:44:52 2018
@@ -682,17 +682,13 @@ public class TorqueInstance
     {
         AbstractBaseManager<?> manager = managers.get(name);
 
-        if (manager == null && className != null && className.length() !=
0)
+        if (manager == null && StringUtils.isNotEmpty(className))
         {
             try
             {
             	AbstractBaseManager<?> newManager = (AbstractBaseManager<?>)
                         Class.forName(className).newInstance();
-                manager = managers.putIfAbsent(name, newManager);
-                if (manager == null)
-                {
-                	manager = newManager;
-                }
+                managers.putIfAbsent(name, newManager);
             }
             catch (Exception e)
             {

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DerbyAdapter.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DerbyAdapter.java?rev=1838900&r1=1838899&r2=1838900&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DerbyAdapter.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/adapter/DerbyAdapter.java
Fri Aug 24 16:44:52 2018
@@ -23,8 +23,6 @@ import java.sql.Connection;
 import java.sql.SQLException;
 import java.sql.Statement;
 
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
 import org.apache.torque.sql.Query;
 
 /**
@@ -41,9 +39,6 @@ public class DerbyAdapter extends Abstra
      */
     private static final long serialVersionUID = 6265962681516206415L;
 
-    /** The class log. */
-    private static Log log = LogFactory.getLog(DerbyAdapter.class);
-
     /**
      * Empty constructor.
      */

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java?rev=1838900&r1=1838899&r2=1838900&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/criteria/Criteria.java
Fri Aug 24 16:44:52 2018
@@ -1211,7 +1211,7 @@ public class Criteria implements Seriali
      * <p>
      * <code>
      * Criteria crit = new Criteria();
-     * Criterion c = new Criterion(XXXPeer.ID, new Integer(5),
+     * Criterion c = new Criterion(XXXPeer.ID, Integer.valueOf(5),
      *         Criteria.LESS_THAN);
      * crit.and(c);
      * </code>
@@ -1574,7 +1574,7 @@ public class Criteria implements Seriali
      * <p>
      * <code>
      * Criteria crit = new Criteria();
-     * Criterion c = new Criterion(XXXPeer.ID, new Integer(5),
+     * Criterion c = new Criterion(XXXPeer.ID, Integer.valueOf(5),
      *         Criteria.LESS_THAN);
      * crit.or(c);
      * </code>

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=1838900&r1=1838899&r2=1838900&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 24 16:44:52 2018
@@ -598,7 +598,7 @@ public abstract class AbstractBaseManage
                 else if (om == null)
                 {
                     // object was removed
-                    listener.removedObject(om);
+                    listener.removedObject(oldOm);
                 }
                 else
                 {

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/om/ComboKey.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/om/ComboKey.java?rev=1838900&r1=1838899&r2=1838900&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/om/ComboKey.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/om/ComboKey.java
Fri Aug 24 16:44:52 2018
@@ -136,7 +136,7 @@ public class ComboKey extends ObjectKey
                         }
                         break;
                     default:
-                        // unextepcted key type
+                        // unexpected key type
                 }
                 tmpKeys.add(newKey);
             }

Modified: db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java?rev=1838900&r1=1838899&r2=1838900&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/util/LargeSelect.java
Fri Aug 24 16:44:52 2018
@@ -25,10 +25,8 @@ import java.io.Serializable;
 import java.sql.Connection;
 import java.util.ArrayList;
 import java.util.Hashtable;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.commons.logging.Log;
@@ -350,7 +348,7 @@ public class LargeSelect<T> implements R
      * <code>pageSize</code> results.
      * @throws TorqueException if a sleep is unexpectedly interrupted.
      */
-    public List<T> getCurrentPageResults() throws TorqueException
+    public synchronized List<T> getCurrentPageResults() throws TorqueException
     {
         return null == lastResults && position > 0
                 ? getResults(position) : lastResults;
@@ -645,7 +643,7 @@ public class LargeSelect<T> implements R
                 log.debug("run(): - results.size(): " + results.size());
             }
         }
-        catch (Exception e)
+        catch (TorqueException e)
         {
             log.error(e);
         }
@@ -739,7 +737,7 @@ public class LargeSelect<T> implements R
 
     /**
      * Retrieve the total number of search result records that are known to
-     * exist (this will be the actual value when the query has completeted (see
+     * exist (this will be the actual value when the query has completed (see
      * <code>getTotalsFinalized()</code>).  The convenience method
      * <code>getRecordProgressText()</code> may be more useful for presenting
to
      * users.
@@ -1133,13 +1131,7 @@ public class LargeSelect<T> implements R
         }
         else
         {
-            Set<String> keys = params.keySet();
-            for (Iterator<String> iter = keys.iterator(); iter.hasNext();)
-            {
-                String key = iter.next();
-                String val = params.get(key);
-                result.append("\n ").append(key).append(": ").append(val);
-            }
+            params.forEach((key, val) -> result.append("\n ").append(key).append(": ").append(val));
         }
         return result.toString();
     }

Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/BaseTestCase.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/BaseTestCase.java?rev=1838900&r1=1838899&r2=1838900&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/BaseTestCase.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/BaseTestCase.java
Fri Aug 24 16:44:52 2018
@@ -91,25 +91,25 @@ public abstract class BaseTestCase exten
         tableMap.setPrimaryKeyMethod(IDMethod.SEQUENCE);
         {
             stringColumnMap = new ColumnMap("COLUMN1", tableMap);
-            stringColumnMap.setType(new String(""));
+            stringColumnMap.setType("");
             stringColumnMap.setJavaType("String");
             tableMap.addColumn(stringColumnMap);
         }
         {
             stringColumnMap2 = new ColumnMap("COLUMN2", tableMap);
-            stringColumnMap2.setType(new String(""));
+            stringColumnMap2.setType("");
             stringColumnMap2.setJavaType("String");
             tableMap.addColumn(stringColumnMap2);
         }
         {
             stringColumnMap3 = new ColumnMap("COLUMN3", tableMap);
-            stringColumnMap3.setType(new String(""));
+            stringColumnMap3.setType("");
             stringColumnMap3.setJavaType("String");
             tableMap.addColumn(stringColumnMap3);
         }
         {
             integerColumnMap = new ColumnMap("COLUMN4", tableMap);
-            integerColumnMap.setType(new Integer(0));
+            integerColumnMap.setType(Integer.valueOf(0));
             integerColumnMap.setJavaType("Integer");
             integerColumnMap.setPk(true);
             tableMap.addColumn(integerColumnMap);

Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriteriaTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriteriaTest.java?rev=1838900&r1=1838899&r2=1838900&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriteriaTest.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriteriaTest.java
Fri Aug 24 16:44:52 2018
@@ -67,25 +67,25 @@ public class CriteriaTest extends BaseTe
             TableMap tableMap = databaseMap.addTable("TABLE");
             {
                 ColumnMap columnMap1 = new ColumnMap("COLUMN1", tableMap);
-                columnMap1.setType(new String(""));
+                columnMap1.setType("");
                 columnMap1.setJavaType("String");
                 tableMap.addColumn(columnMap1);
             }
             {
                 ColumnMap columnMap2 = new ColumnMap("COLUMN2", tableMap);
-                columnMap2.setType(new String(""));
+                columnMap2.setType("");
                 columnMap2.setJavaType("String");
                 tableMap.addColumn(columnMap2);
             }
             {
                 ColumnMap columnMap3 = new ColumnMap("COLUMN3", tableMap);
-                columnMap3.setType(new String(""));
+                columnMap3.setType("");
                 columnMap3.setJavaType("String");
                 tableMap.addColumn(columnMap3);
             }
             {
                 ColumnMap columnMap4 = new ColumnMap("COLUMN4", tableMap);
-                columnMap4.setType(new Integer(0));
+                columnMap4.setType(Integer.valueOf(0));
                 columnMap4.setJavaType("Integer");
                 tableMap.addColumn(columnMap4);
             }
@@ -482,7 +482,7 @@ public class CriteriaTest extends BaseTe
         Criterion criterion3 = new Criterion(
                 new ColumnImpl("TABLE", "COLUMN3"), "FoObAr3", Criteria.EQUAL);
         Criterion criterion4 = new Criterion(
-                new ColumnImpl("TABLE", "COLUMN4"), new Integer(1), Criteria.EQUAL);
+                new ColumnImpl("TABLE", "COLUMN4"), Integer.valueOf(1), Criteria.EQUAL);
         criterion4.setIgnoreCase(true);
         c.where(criterion1.and(criterion2).and(criterion3).and(criterion4));
         c.addSelectColumn(new ColumnImpl(null, "TABLE", null, "*"));
@@ -499,7 +499,7 @@ public class CriteriaTest extends BaseTe
         assertEquals("FoObAr1", replacements.get(0));
         assertEquals("FoObAr2", replacements.get(1));
         assertEquals("FoObAr3", replacements.get(2));
-        assertEquals(new Integer(1), replacements.get(3));
+        assertEquals(Integer.valueOf(1), replacements.get(3));
     }
 
     /**
@@ -990,7 +990,7 @@ public class CriteriaTest extends BaseTe
         tableMap.addColumn(columnMap);
 
         columnMap = new ColumnMap("AUTHOR_ID", tableMap);
-        columnMap.setType(new Integer(0));
+        columnMap.setType(Integer.valueOf(0));
         tableMap.addColumn(columnMap);
 
         // check that alias'ed tables are referenced by their alias

Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java?rev=1838900&r1=1838899&r2=1838900&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/criteria/CriterionTest.java
Fri Aug 24 16:44:52 2018
@@ -19,6 +19,8 @@ package org.apache.torque.criteria;
  * under the License.
  */
 
+import static org.junit.Assert.assertArrayEquals;
+
 import org.apache.torque.BaseTestCase;
 import org.apache.torque.ColumnImpl;
 
@@ -187,7 +189,7 @@ public class CriterionTest extends BaseT
         assertNull(criterion.getComparison());
         assertNull(criterion.getRValue());
         assertEquals(criterion.getSql(), copied.getSql());
-        assertEquals(
+        assertArrayEquals(
                 criterion.getPreparedStatementReplacements(),
                 copied.getPreparedStatementReplacements());
         assertFalse(copied.isIgnoreCase());

Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/om/NumberKeyTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/om/NumberKeyTest.java?rev=1838900&r1=1838899&r2=1838900&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/om/NumberKeyTest.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/om/NumberKeyTest.java
Fri Aug 24 16:44:52 2018
@@ -77,8 +77,8 @@ public class NumberKeyTest extends TestC
 
         assertFalse("1".equals(n1a));
         assertFalse(n1a.equals("1"));
-        assertFalse(n1a.equals(new Integer(1)));
-        assertFalse(new Integer(1).equals(n1a));
+        assertFalse(n1a.equals(Integer.valueOf(1)));
+        assertFalse(Integer.valueOf(1).equals(n1a));
     }
 
     /**
@@ -180,7 +180,7 @@ public class NumberKeyTest extends TestC
      */
     public void testNumberConstructor()
     {
-        NumberKey key = new NumberKey(new Integer(432));
+        NumberKey key = new NumberKey(Integer.valueOf(432));
         assertEquals("432", key.toString());
     }
 

Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/om/mapper/CompositeMapperTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/om/mapper/CompositeMapperTest.java?rev=1838900&r1=1838899&r2=1838900&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/om/mapper/CompositeMapperTest.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/om/mapper/CompositeMapperTest.java
Fri Aug 24 16:44:52 2018
@@ -64,7 +64,7 @@ public class CompositeMapperTest extends
         when(recordMapper1.processRow(resultSet,3, criteria))
             .thenReturn(null);
         when(recordMapper2.processRow(resultSet, 4, criteria))
-            .thenReturn(new Integer(1));
+            .thenReturn(Integer.valueOf(1));
         when(recordMapper3.processRow(resultSet, 5, criteria))
             .thenReturn(new Long(2));
 
@@ -87,7 +87,7 @@ public class CompositeMapperTest extends
         // verify
         assertEquals(3, result.size());
         assertEquals(null, result.get(0));
-        assertEquals(new Integer(1), result.get(1));
+        assertEquals(Integer.valueOf(1), result.get(1));
         assertEquals(new Long(2), result.get(2));
         verify(recordMapper1).processRow(resultSet, 3, criteria);
         verify(recordMapper2).processRow(resultSet, 4, criteria);

Modified: db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/SummaryHelperTest.java
URL: http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/SummaryHelperTest.java?rev=1838900&r1=1838899&r2=1838900&view=diff
==============================================================================
--- db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/SummaryHelperTest.java
(original)
+++ db/torque/torque4/trunk/torque-runtime/src/test/java/org/apache/torque/util/SummaryHelperTest.java
Fri Aug 24 16:44:52 2018
@@ -95,25 +95,25 @@ public class SummaryHelperTest extends B
         tableMap = databaseMap.addTable("TABLE");
         {
             columnMap1 = new ColumnMap("COLUMN1", tableMap);
-            columnMap1.setType(new String(""));
+            columnMap1.setType("");
             columnMap1.setJavaType("String");
             tableMap.addColumn(columnMap1);
         }
         {
             columnMap2 = new ColumnMap("COLUMN2", tableMap);
-            columnMap2.setType(new String(""));
+            columnMap2.setType("");
             columnMap2.setJavaType("String");
             tableMap.addColumn(columnMap2);
         }
         {
             columnMap3 = new ColumnMap("COLUMN3", tableMap);
-            columnMap3.setType(new String(""));
+            columnMap3.setType("");
             columnMap3.setJavaType("String");
             tableMap.addColumn(columnMap3);
         }
         {
             columnMap4 = new ColumnMap("COLUMN4", tableMap);
-            columnMap4.setType(new Integer(0));
+            columnMap4.setType(Integer.valueOf(0));
             columnMap4.setJavaType("Integer");
             tableMap.addColumn(columnMap4);
         }



---------------------------------------------------------------------
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