db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r359584 - in /db/torque/runtime/trunk/src/java/org/apache/torque: ./ dsfactory/ manager/ util/
Date Wed, 28 Dec 2005 18:36:43 GMT
Author: tv
Date: Wed Dec 28 10:36:21 2005
New Revision: 359584

URL: http://svn.apache.org/viewcvs?rev=359584&view=rev
Log:
fixed some Findbugs and PMD related issues.

Modified:
    db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java
    db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
    db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java
    db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java
    db/torque/runtime/trunk/src/java/org/apache/torque/manager/AbstractBaseManager.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/SQLBuilder.java
    db/torque/runtime/trunk/src/java/org/apache/torque/util/VillageUtils.java

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java?rev=359584&r1=359583&r2=359584&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/TorqueInstance.java Wed Dec 28 10:36:21
2005
@@ -33,7 +33,6 @@
 import org.apache.commons.logging.LogFactory;
 import org.apache.torque.adapter.DB;
 import org.apache.torque.adapter.DBFactory;
-import org.apache.torque.dsfactory.AbstractDataSourceFactory;
 import org.apache.torque.dsfactory.DataSourceFactory;
 import org.apache.torque.manager.AbstractBaseManager;
 import org.apache.torque.map.DatabaseMap;
@@ -813,9 +812,6 @@
     public Connection getConnection(String name)
             throws TorqueException
     {
-        Connection con = null;
-        DataSourceFactory dsf = null;
-
         try
         {
             return getDataSourceFactory(name).getDataSource().getConnection();

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java?rev=359584&r1=359583&r2=359584&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
(original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/JndiDataSourceFactory.java
Wed Dec 28 10:36:21 2005
@@ -48,7 +48,6 @@
  */
 public class JndiDataSourceFactory
     extends AbstractDataSourceFactory
-    implements DataSourceFactory
 {
 
     /** The log. */
@@ -243,12 +242,12 @@
     {
         log.debug("InitialContext -------------------------------");
         Map env = ctx.getEnvironment();
-        Iterator qw = env.keySet().iterator();
+        Iterator qw = env.entrySet().iterator();
         log.debug("Environment properties:" + env.size());
         while (qw.hasNext())
         {
-            Object prop = qw.next();
-            log.debug("    " + prop + ": " + env.get(prop));
+            Map.Entry entry = (Map.Entry)qw.next(); 
+            log.debug("    " + entry.getKey() + ": " + entry.getValue());
         }
         log.debug("----------------------------------------------");
     }

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java?rev=359584&r1=359583&r2=359584&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java
(original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/PerUserPoolDataSourceFactory.java
Wed Dec 28 10:36:21 2005
@@ -38,7 +38,6 @@
  */
 public class PerUserPoolDataSourceFactory
     extends AbstractDataSourceFactory
-    implements DataSourceFactory
 {
 
     /** The log. */
@@ -46,7 +45,7 @@
             = LogFactory.getLog(PerUserPoolDataSourceFactory.class);
 
     /** The wrapped <code>DataSource</code>. */
-    private PerUserPoolDataSource ds;
+    private PerUserPoolDataSource ds = null;
 
     /**
      * @see org.apache.torque.dsfactory.DataSourceFactory#getDataSource

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java?rev=359584&r1=359583&r2=359584&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java
(original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/dsfactory/SharedPoolDataSourceFactory.java
Wed Dec 28 10:36:21 2005
@@ -38,7 +38,6 @@
  */
 public class SharedPoolDataSourceFactory
     extends AbstractDataSourceFactory
-    implements DataSourceFactory
 {
 
     /** The log. */
@@ -46,7 +45,7 @@
             = LogFactory.getLog(SharedPoolDataSourceFactory.class);
 
     /** The wrapped <code>DataSource</code>. */
-    private SharedPoolDataSource ds;
+    private SharedPoolDataSource ds = null;
 
     /**
      * @see org.apache.torque.dsfactory.DataSourceFactory#getDataSource

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/manager/AbstractBaseManager.java
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/java/org/apache/torque/manager/AbstractBaseManager.java?rev=359584&r1=359583&r2=359584&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/manager/AbstractBaseManager.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/manager/AbstractBaseManager.java Wed
Dec 28 10:36:21 2005
@@ -51,7 +51,7 @@
     implements Serializable
 {
     /** the log */
-    protected static Log log = LogFactory.getLog(AbstractBaseManager.class);
+    protected static final Log log = LogFactory.getLog(AbstractBaseManager.class);
 
     /** used to cache the om objects. cache is set by the region property */
     protected transient GroupCacheAccess cache;
@@ -439,10 +439,11 @@
                 mrCache = new NoOpMethodResultCache(cache);
             }
         }
-        catch (Exception e)
+        catch (CacheException e)
         {
             throw new TorqueException("Cache could not be initialized", e);
         }
+        
         if (cache == null)
         {
             log.info("Cache could not be initialized for region: " + v);

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java?rev=359584&r1=359583&r2=359584&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/BasePeer.java Wed Dec 28 10:36:21
2005
@@ -47,6 +47,7 @@
 
 import com.workingdogs.village.Column;
 import com.workingdogs.village.DataSet;
+import com.workingdogs.village.DataSetException;
 import com.workingdogs.village.KeyDef;
 import com.workingdogs.village.QueryDataSet;
 import com.workingdogs.village.Record;
@@ -89,7 +90,7 @@
     private static Hashtable mapBuilders = new Hashtable(5);
 
     /** the log */
-    protected static Log log = LogFactory.getLog(BasePeer.class);
+    protected static final Log log = LogFactory.getLog(BasePeer.class);
 
     private static void throwTorqueException(Exception e)
         throws TorqueException
@@ -259,8 +260,9 @@
                 {
                     statement.close();
                 }
-                catch (SQLException ignored)
+                catch (SQLException e)
                 {
+                    throw new TorqueException(e);
                 }
             }
         }
@@ -332,7 +334,6 @@
         throws TorqueException
     {
         String dbName = criteria.getDbName();
-        final DB db = Torque.getDB(dbName);
         final DatabaseMap dbMap = Torque.getDatabaseMap(dbName);
 
         // This Callback adds all tables to the Table set which
@@ -494,12 +495,6 @@
             // we're inserting into.
             if (pk != null && !criteria.containsKey(pk.getFullyQualifiedName()))
             {
-                if (keyGen == null)
-                {
-                    throw new TorqueException(
-                            "IdGenerator for table '" + table + "' is null");
-                }
-
                 id = getId(pk, keyGen, con, keyInfo);
                 criteria.add(pk.getFullyQualifiedName(), id);
             }
@@ -515,7 +510,15 @@
             // not the fully qualified name, insertOrUpdateRecord wants to use table as an
index...
             BasePeer.insertOrUpdateRecord(rec, table, dbName, criteria);
         }
-        catch (Exception e)
+        catch (DataSetException e)
+        {
+            throwTorqueException(e);
+        }
+        catch (SQLException e)
+        {
+            throwTorqueException(e);
+        }
+        catch (TorqueException e)
         {
             throwTorqueException(e);
         }
@@ -894,7 +897,11 @@
             results = getSelectResults(
                     qds, start, numberOfResults, singleRecord);
         }
-        catch (Exception e)
+        catch (DataSetException e)
+        {
+            throwTorqueException(e);
+        }
+        catch (SQLException e)
         {
             throwTorqueException(e);
         }
@@ -1206,10 +1213,6 @@
         Connection con)
         throws TorqueException
     {
-        String dbName = criteria.getDbName();
-        DB db = Torque.getDB(dbName);
-        DatabaseMap dbMap = Torque.getDatabaseMap(dbName);
-
         Set tables = SQLBuilder.getTableSet(criteria, null);
 
         try
@@ -1444,7 +1447,11 @@
                 VillageUtils.close(qds);
             }
         }
-        catch (Exception e)
+        catch (DataSetException e)
+        {
+            throwTorqueException(e);
+        }
+        catch (SQLException e)
         {
             throwTorqueException(e);
         }

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java?rev=359584&r1=359583&r2=359584&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/Criteria.java Wed Dec 28 10:36:21
2005
@@ -3090,13 +3090,13 @@
 
         // Criteria.put() differs somewhat from Hashtable.put().
         // This necessitates some corrective behavior upon deserialization.
-        for (Iterator iter = keySet().iterator(); iter.hasNext();)
+        for (Iterator iter = entrySet().iterator(); iter.hasNext();)
         {
-            Object key = iter.next();
-            Object value = get(key);
+            Map.Entry entry = (Map.Entry)iter.next();
+            Object value = entry.getValue();
             if (value instanceof Criteria.Criterion)
             {
-                super.put(key, value);
+                super.put(entry.getKey(), value);
             }
         }
 

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/SQLBuilder.java
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/java/org/apache/torque/util/SQLBuilder.java?rev=359584&r1=359583&r2=359584&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/SQLBuilder.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/SQLBuilder.java Wed Dec 28 10:36:21
2005
@@ -404,7 +404,6 @@
             final QueryCallback qc)
         throws TorqueException
     {
-        UniqueList fromClause = query.getFromClause();
         UniqueList whereClause = query.getWhereClause();
 
         for (Iterator it = crit.keySet().iterator(); it.hasNext(); )

Modified: db/torque/runtime/trunk/src/java/org/apache/torque/util/VillageUtils.java
URL: http://svn.apache.org/viewcvs/db/torque/runtime/trunk/src/java/org/apache/torque/util/VillageUtils.java?rev=359584&r1=359583&r2=359584&view=diff
==============================================================================
--- db/torque/runtime/trunk/src/java/org/apache/torque/util/VillageUtils.java (original)
+++ db/torque/runtime/trunk/src/java/org/apache/torque/util/VillageUtils.java Wed Dec 28 10:36:21
2005
@@ -24,8 +24,8 @@
 import java.math.BigDecimal;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.Map;
 
-import org.apache.torque.TorqueException;
 import org.apache.torque.om.SimpleKey;
 
 import com.workingdogs.village.QueryDataSet;
@@ -113,18 +113,15 @@
         throws Exception
     {
         Hashtable saveData = new Hashtable(hash.size());
-        String key = null;
-        Object value = null;
         byte[] byteArray = null;
 
-        Iterator keys = hash.keySet().iterator();
+        Iterator keys = hash.entrySet().iterator();
         while (keys.hasNext())
         {
-            key = (String) keys.next();
-            value = hash.get(key);
-            if (value instanceof Serializable)
+            Map.Entry entry = (Map.Entry)keys.next();
+            if (entry.getValue() instanceof Serializable)
             {
-                saveData.put(key, value);
+                saveData.put(entry.getKey(), entry.getValue());
             }
         }
 



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