commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ma...@apache.org
Subject svn commit: r1572032 - in /commons/proper/dbcp/trunk/src: main/java/org/apache/commons/dbcp2/datasources/ test/java/org/apache/commons/dbcp2/datasources/
Date Wed, 26 Feb 2014 12:36:06 GMT
Author: markt
Date: Wed Feb 26 12:36:05 2014
New Revision: 1572032

URL: http://svn.apache.org/r1572032
Log:
Remove unused code identified by PMD

Modified:
    commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
    commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java

Modified: commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java?rev=1572032&r1=1572031&r2=1572032&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
Wed Feb 26 12:36:05 2014
@@ -846,15 +846,15 @@ public class PerUserPoolDataSource exten
      * Get the number of active connections in the default pool.
      */
     public int getNumActive() {
-        return getNumActive(null, null);
+        return getNumActive(null);
     }
 
     /**
      * Get the number of active connections in the pool for a given user.
      */
-    public int getNumActive(String username, String password) {
+    public int getNumActive(String username) {
         ObjectPool<PooledConnectionAndInfo> pool =
-            getPool(getPoolKey(username,password));
+            getPool(getPoolKey(username));
         return pool == null ? 0 : pool.getNumActive();
     }
 
@@ -862,15 +862,15 @@ public class PerUserPoolDataSource exten
      * Get the number of idle connections in the default pool.
      */
     public int getNumIdle() {
-        return getNumIdle(null, null);
+        return getNumIdle(null);
     }
 
     /**
      * Get the number of idle connections in the pool for a given user.
      */
-    public int getNumIdle(String username, String password) {
+    public int getNumIdle(String username) {
         ObjectPool<PooledConnectionAndInfo> pool =
-            getPool(getPoolKey(username,password));
+            getPool(getPoolKey(username));
         return pool == null ? 0 : pool.getNumIdle();
     }
 
@@ -883,7 +883,7 @@ public class PerUserPoolDataSource exten
         getPooledConnectionAndInfo(String username, String password)
         throws SQLException {
 
-        final PoolKey key = getPoolKey(username,password);
+        final PoolKey key = getPoolKey(username);
         ObjectPool<PooledConnectionAndInfo> pool;
         PooledConnectionManager manager;
         synchronized(this) {
@@ -980,8 +980,7 @@ public class PerUserPoolDataSource exten
 
     @Override
     protected PooledConnectionManager getConnectionManager(UserPassKey upkey) {
-        return managers.get(
-                getPoolKey(upkey.getUsername(), upkey.getPassword()));
+        return managers.get(getPoolKey(upkey.getUsername()));
     }
 
     /**
@@ -1001,10 +1000,9 @@ public class PerUserPoolDataSource exten
      * Create a pool key from the provided parameters.
      *
      * @param username  User name
-     * @param password  Not currently used
      * @return  The pool key
      */
-    private PoolKey getPoolKey(String username, String password) {
+    private PoolKey getPoolKey(String username) {
         return new PoolKey(getDataSourceName(), username);
     }
 
@@ -1048,7 +1046,7 @@ public class PerUserPoolDataSource exten
 
         pool.setSwallowedExceptionListener(new SwallowedExceptionLogger(log));
 
-        Object old = managers.put(getPoolKey(username,password), factory);
+        Object old = managers.put(getPoolKey(username), factory);
         if (old != null) {
             throw new IllegalStateException("Pool already contains an entry for this user/password:
" + username);
         }

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java?rev=1572032&r1=1572031&r2=1572032&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestCPDSConnectionFactory.java
Wed Feb 26 12:36:05 2014
@@ -71,13 +71,13 @@ public class TestCPDSConnectionFactory e
        Connection conn1 = ds.getConnection("username", "password");
        Connection conn2 = ds.getConnection("username", "password");
        Connection conn3 = ds.getConnection("username", "password");
-       assertEquals(3, ds.getNumActive("username", "password"));
+       assertEquals(3, ds.getNumActive("username"));
        conn1.close();
-       assertEquals(1, ds.getNumIdle("username", "password"));
+       assertEquals(1, ds.getNumIdle("username"));
        conn2.close();
-       assertEquals(2, ds.getNumIdle("username", "password"));
+       assertEquals(2, ds.getNumIdle("username"));
        conn3.close(); // Return to pool will trigger destroy -> close sequence
-       assertEquals(2, ds.getNumIdle("username", "password"));
+       assertEquals(2, ds.getNumIdle("username"));
     }
 
     /**

Modified: commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java?rev=1572032&r1=1572031&r2=1572032&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
(original)
+++ commons/proper/dbcp/trunk/src/test/java/org/apache/commons/dbcp2/datasources/TestPerUserPoolDataSource.java
Wed Feb 26 12:36:05 2014
@@ -342,45 +342,45 @@ public class TestPerUserPoolDataSource e
         tds.setPerUserMaxTotal("u2", Integer.valueOf(5));
 
         assertEquals(0, tds.getNumActive());
-        assertEquals(0, tds.getNumActive("u1", "p1"));
-        assertEquals(0, tds.getNumActive("u2", "p2"));
+        assertEquals(0, tds.getNumActive("u1"));
+        assertEquals(0, tds.getNumActive("u2"));
         assertEquals(0, tds.getNumIdle());
-        assertEquals(0, tds.getNumIdle("u1", "p1"));
-        assertEquals(0, tds.getNumIdle("u2", "p2"));
+        assertEquals(0, tds.getNumIdle("u1"));
+        assertEquals(0, tds.getNumIdle("u2"));
 
         Connection conn = tds.getConnection();
         assertNotNull(conn);
         assertEquals(1, tds.getNumActive());
-        assertEquals(0, tds.getNumActive("u1", "p1"));
-        assertEquals(0, tds.getNumActive("u2", "p2"));
+        assertEquals(0, tds.getNumActive("u1"));
+        assertEquals(0, tds.getNumActive("u2"));
         assertEquals(0, tds.getNumIdle());
-        assertEquals(0, tds.getNumIdle("u1", "p1"));
-        assertEquals(0, tds.getNumIdle("u2", "p2"));
+        assertEquals(0, tds.getNumIdle("u1"));
+        assertEquals(0, tds.getNumIdle("u2"));
 
         conn.close();
         assertEquals(0, tds.getNumActive());
-        assertEquals(0, tds.getNumActive("u1", "p1"));
-        assertEquals(0, tds.getNumActive("u2", "p2"));
+        assertEquals(0, tds.getNumActive("u1"));
+        assertEquals(0, tds.getNumActive("u2"));
         assertEquals(1, tds.getNumIdle());
-        assertEquals(0, tds.getNumIdle("u1", "p1"));
-        assertEquals(0, tds.getNumIdle("u2", "p2"));
+        assertEquals(0, tds.getNumIdle("u1"));
+        assertEquals(0, tds.getNumIdle("u2"));
 
         conn = tds.getConnection("u1", "p1");
         assertNotNull(conn);
         assertEquals(0, tds.getNumActive());
-        assertEquals(1, tds.getNumActive("u1", "p1"));
-        assertEquals(0, tds.getNumActive("u2", "p2"));
+        assertEquals(1, tds.getNumActive("u1"));
+        assertEquals(0, tds.getNumActive("u2"));
         assertEquals(1, tds.getNumIdle());
-        assertEquals(0, tds.getNumIdle("u1", "p1"));
-        assertEquals(0, tds.getNumIdle("u2", "p2"));
+        assertEquals(0, tds.getNumIdle("u1"));
+        assertEquals(0, tds.getNumIdle("u2"));
 
         conn.close();
         assertEquals(0, tds.getNumActive());
-        assertEquals(0, tds.getNumActive("u1", "p1"));
-        assertEquals(0, tds.getNumActive("u2", "p2"));
+        assertEquals(0, tds.getNumActive("u1"));
+        assertEquals(0, tds.getNumActive("u2"));
         assertEquals(1, tds.getNumIdle());
-        assertEquals(1, tds.getNumIdle("u1", "p1"));
-        assertEquals(0, tds.getNumIdle("u2", "p2"));
+        assertEquals(1, tds.getNumIdle("u1"));
+        assertEquals(0, tds.getNumIdle("u2"));
     }
 
     public void testMultipleThreads1() throws Exception {
@@ -459,14 +459,14 @@ public class TestPerUserPoolDataSource e
         assertNotNull(conn);
         assertEquals(0, tds.getNumActive());
         assertEquals(1, tds.getNumIdle());
-        assertEquals(1, tds.getNumActive("u1", "p1"));
-        assertEquals(0, tds.getNumIdle("u1", "p1"));
+        assertEquals(1, tds.getNumActive("u1"));
+        assertEquals(0, tds.getNumIdle("u1"));
 
         conn.close();
         assertEquals(0, tds.getNumActive());
         assertEquals(1, tds.getNumIdle());
-        assertEquals(0, tds.getNumActive("u1", "p1"));
-        assertEquals(1, tds.getNumIdle("u1", "p1"));
+        assertEquals(0, tds.getNumActive("u1"));
+        assertEquals(1, tds.getNumIdle("u1"));
     }
 
     // see issue http://issues.apache.org/bugzilla/show_bug.cgi?id=23843
@@ -526,11 +526,11 @@ public class TestPerUserPoolDataSource e
             Connection con4 = ds.getConnection("foo", "bay"); // new password
             // Idle instances with old password should have been cleared
             assertEquals("Should be no idle connections in the pool",
-                    0, ((PerUserPoolDataSource) ds).getNumIdle("foo", "bar"));
+                    0, ((PerUserPoolDataSource) ds).getNumIdle("foo"));
             con4.close();
             // Should be one idle instance with new pwd
             assertEquals("Should be one idle connection in the pool",
-                    1, ((PerUserPoolDataSource) ds).getNumIdle("foo", "bay"));
+                    1, ((PerUserPoolDataSource) ds).getNumIdle("foo"));
             try {
                 ds.getConnection("foo", "bar"); // old password
                 fail("Should have generated SQLException");
@@ -540,7 +540,7 @@ public class TestPerUserPoolDataSource e
             con3.close(); // Return a connection with the old password
             ds.getConnection("foo", "bay").close();  // will try bad returned connection
and destroy it
             assertEquals("Should be one idle connection in the pool",
-                    1, ((PerUserPoolDataSource) ds).getNumIdle("foo", "bar"));
+                    1, ((PerUserPoolDataSource) ds).getNumIdle("foo"));
             con5.close();
         } finally {
             TesterDriver.addUser("foo","bar");



Mime
View raw message