You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ma...@apache.org on 2014/01/30 21:53:41 UTC

svn commit: r1562957 - /commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java

Author: markt
Date: Thu Jan 30 20:53:41 2014
New Revision: 1562957

URL: http://svn.apache.org/r1562957
Log:
Add a test case for DBCP-369. It current passes need to check if there is still a bug here.

Modified:
    commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java

Modified: commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java
URL: http://svn.apache.org/viewvc/commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java?rev=1562957&r1=1562956&r2=1562957&view=diff
==============================================================================
--- commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java (original)
+++ commons/proper/dbcp/trunk/src/test/org/apache/commons/dbcp2/datasources/TestSharedPoolDataSource.java Thu Jan 30 20:53:41 2014
@@ -21,6 +21,7 @@ import java.sql.Connection;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
+import java.util.ArrayList;
 
 import javax.sql.DataSource;
 
@@ -603,4 +604,44 @@ public class TestSharedPoolDataSource ex
             TesterDriver.addUser("foo","bar");
         }
     }
+
+    public void testDbcp369() {
+        final ArrayList<SharedPoolDataSource> dataSources = new ArrayList<>();
+        for (int j = 0; j < 10000; j++) {
+            SharedPoolDataSource dataSource = new SharedPoolDataSource();
+            dataSources.add(dataSource);
+        }
+
+        Thread t1 = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                for (SharedPoolDataSource dataSource : dataSources) {
+                    dataSource.setDataSourceName("a");
+                }
+            }
+        });
+
+        Thread t2 = new Thread(new Runnable() {
+            @Override
+            public void run() {
+                for (SharedPoolDataSource dataSource : dataSources) {
+                    try {
+                        dataSource.close();
+                    } catch (Exception e) {
+                        // Ignore
+                    }
+                }
+            }
+        });
+
+        t1.start();
+        t2.start();
+
+        try {
+            t1.join();
+            t2.join();
+        } catch (InterruptedException ie) {
+            // Ignore
+        }
+    }
 }