cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [1/4] cayenne git commit: Cayenne 4.0 connection pool is occasionally running out of connections
Date Wed, 09 Mar 2016 19:29:11 GMT
Repository: cayenne
Updated Branches:
  refs/heads/master 0e0da8064 -> b0631deb2


Cayenne 4.0 connection pool is occasionally running out of connections

* refactoring existing test. It doesn't seem to do the right thing

Project: http://git-wip-us.apache.org/repos/asf/cayenne/repo
Commit: http://git-wip-us.apache.org/repos/asf/cayenne/commit/2bc74c26
Tree: http://git-wip-us.apache.org/repos/asf/cayenne/tree/2bc74c26
Diff: http://git-wip-us.apache.org/repos/asf/cayenne/diff/2bc74c26

Branch: refs/heads/master
Commit: 2bc74c2645c71acf22125ad1e24d82728fd8f71d
Parents: 0e0da80
Author: Andrus Adamchik <andrus@objectstyle.com>
Authored: Wed Mar 9 07:49:10 2016 -0800
Committer: Andrus Adamchik <andrus@objectstyle.com>
Committed: Wed Mar 9 07:49:10 2016 -0800

----------------------------------------------------------------------
 .../apache/cayenne/datasource/PoolingDataSourceIT.java | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cayenne/blob/2bc74c26/cayenne-server/src/test/java/org/apache/cayenne/datasource/PoolingDataSourceIT.java
----------------------------------------------------------------------
diff --git a/cayenne-server/src/test/java/org/apache/cayenne/datasource/PoolingDataSourceIT.java
b/cayenne-server/src/test/java/org/apache/cayenne/datasource/PoolingDataSourceIT.java
index 68bbef2..d7d8bf1 100644
--- a/cayenne-server/src/test/java/org/apache/cayenne/datasource/PoolingDataSourceIT.java
+++ b/cayenne-server/src/test/java/org/apache/cayenne/datasource/PoolingDataSourceIT.java
@@ -174,8 +174,8 @@ public class PoolingDataSourceIT extends BasePoolingDataSourceIT {
 		ExecutorService executor = Executors.newFixedThreadPool(tasks.length);
 
 		for (int j = 0; j < 100; j++) {
-			for (int i = 0; i < tasks.length; i++) {
-				executor.submit(tasks[i]);
+			for (PoolTask task : tasks) {
+				executor.submit(task);
 			}
 		}
 
@@ -192,8 +192,8 @@ public class PoolingDataSourceIT extends BasePoolingDataSourceIT {
 			throw new RuntimeException(e);
 		}
 
-		for (int i = 0; i < tasks.length; i++) {
-			assertEquals(100, tasks[i].i.get());
+		for (PoolTask task : tasks) {
+			assertEquals(100, task.i.get());
 		}
 	}
 
@@ -204,7 +204,6 @@ public class PoolingDataSourceIT extends BasePoolingDataSourceIT {
 		@Override
 		public void run() {
 
-			i.incrementAndGet();
 			try {
 				Connection c = dataSource.getConnection();
 				try {
@@ -220,6 +219,7 @@ public class PoolingDataSourceIT extends BasePoolingDataSourceIT {
 						} finally {
 							rs.close();
 						}
+
 					} finally {
 						st.close();
 					}
@@ -228,6 +228,9 @@ public class PoolingDataSourceIT extends BasePoolingDataSourceIT {
 					c.close();
 				}
 
+				// increment only after success
+				i.incrementAndGet();
+
 			} catch (SQLException e) {
 				e.printStackTrace();
 			}


Mime
View raw message