You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2018/06/09 14:59:54 UTC
commons-dbcp git commit: Refactor commons code into a private method;
Javadoc nits.
Repository: commons-dbcp
Updated Branches:
refs/heads/master 31dac7eb1 -> b6c122608
Refactor commons code into a private method; Javadoc nits.
Project: http://git-wip-us.apache.org/repos/asf/commons-dbcp/repo
Commit: http://git-wip-us.apache.org/repos/asf/commons-dbcp/commit/b6c12260
Tree: http://git-wip-us.apache.org/repos/asf/commons-dbcp/tree/b6c12260
Diff: http://git-wip-us.apache.org/repos/asf/commons-dbcp/diff/b6c12260
Branch: refs/heads/master
Commit: b6c1226082e9272a3a5eb37422afc24740e7b75d
Parents: 31dac7e
Author: Gary Gregory <ga...@gmail.com>
Authored: Sat Jun 9 08:59:51 2018 -0600
Committer: Gary Gregory <ga...@gmail.com>
Committed: Sat Jun 9 08:59:51 2018 -0600
----------------------------------------------------------------------
.../datasources/PerUserPoolDataSource.java | 31 +++++++++++---------
1 file changed, 17 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/commons-dbcp/blob/b6c12260/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java b/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
index de70046..b6d3c63 100644
--- a/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
+++ b/src/main/java/org/apache/commons/dbcp2/datasources/PerUserPoolDataSource.java
@@ -85,12 +85,12 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
private Map<String, Boolean> perUserDefaultReadOnly;
/**
- * Map to keep track of Pools for a given user
+ * Map to keep track of Pools for a given user.
*/
private transient Map<PoolKey, PooledConnectionManager> managers = new HashMap<>();
/**
- * Default no-arg constructor for Serialization
+ * Default no-arg constructor for Serialization.
*/
public PerUserPoolDataSource() {
}
@@ -104,9 +104,9 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
public void clear() {
for (final PooledConnectionManager manager : managers.values()) {
try {
- ((CPDSConnectionFactory) manager).getPool().clear();
+ getCPDSConnectionFactoryPool(manager).clear();
} catch (final Exception closePoolException) {
- //ignore and try to close others.
+ // ignore and try to close others.
}
}
InstanceKeyDataSourceFactory.removeInstance(getInstanceKey());
@@ -121,7 +121,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
public void close() {
for (final PooledConnectionManager manager : managers.values()) {
try {
- ((CPDSConnectionFactory) manager).getPool().close();
+ getCPDSConnectionFactoryPool(manager).close();
} catch (final Exception closePoolException) {
// ignore and try to close others.
}
@@ -139,6 +139,10 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return managers.get(getPoolKey(upkey.getUsername()));
}
+ private ObjectPool<PooledConnectionAndInfo> getCPDSConnectionFactoryPool(PooledConnectionManager manager) {
+ return ((CPDSConnectionFactory) manager).getPool();
+ }
+
/**
* Gets the number of active connections in the default pool.
*
@@ -148,7 +152,6 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return getNumActive(null);
}
-
/**
* Gets the number of active connections in the pool for a given user.
*
@@ -170,6 +173,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return getNumIdle(null);
}
+
/**
* Gets the number of idle connections in the pool for a given user.
*
@@ -182,7 +186,6 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return pool == null ? 0 : pool.getNumIdle();
}
-
/**
* Gets the user specific value for {@link GenericObjectPool#getBlockWhenExhausted()} for the specified user's pool
* or the default if no user specific value is defined.
@@ -217,6 +220,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value;
}
+
/**
* Gets the user specific default value for {@link Connection#setReadOnly(boolean)} for the specified user's pool.
*
@@ -232,7 +236,6 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value;
}
-
/**
* Gets the user specific default value for {@link Connection#setTransactionIsolation(int)} for the specified user's
* pool.
@@ -268,6 +271,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value;
}
+
/**
* Gets the user specific value for {@link GenericObjectPool#getLifo()} for the specified user's pool or the default
* if no user specific value is defined.
@@ -287,7 +291,6 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value.booleanValue();
}
-
/**
* Gets the user specific value for {@link GenericObjectPool#getMaxIdle()} for the specified user's pool or the
* default if no user specific value is defined.
@@ -326,6 +329,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value.intValue();
}
+
/**
* Gets the user specific value for {@link GenericObjectPool#getMaxWaitMillis()} for the specified user's pool or
* the default if no user specific value is defined.
@@ -345,7 +349,6 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value.longValue();
}
-
/**
* Gets the user specific value for {@link GenericObjectPool#getMinEvictableIdleTimeMillis()} for the specified
* user's pool or the default if no user specific value is defined.
@@ -384,6 +387,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value.intValue();
}
+
/**
* Gets the user specific value for {@link GenericObjectPool#getNumTestsPerEvictionRun()} for the specified user's
* pool or the default if no user specific value is defined.
@@ -403,7 +407,6 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value.intValue();
}
-
/**
* Gets the user specific value for {@link GenericObjectPool#getSoftMinEvictableIdleTimeMillis()} for the specified
* user's pool or the default if no user specific value is defined.
@@ -442,6 +445,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value.booleanValue();
}
+
/**
* Gets the user specific value for {@link GenericObjectPool#getTestOnCreate()} for the specified user's pool or the
* default if no user specific value is defined.
@@ -461,7 +465,6 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value.booleanValue();
}
-
/**
* Gets the user specific value for {@link GenericObjectPool#getTestOnReturn()} for the specified user's pool or the
* default if no user specific value is defined.
@@ -500,6 +503,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value.booleanValue();
}
+
/**
* Gets the user specific value for {@link GenericObjectPool#getTimeBetweenEvictionRunsMillis()} for the specified
* user's pool or the default if no user specific value is defined.
@@ -519,7 +523,6 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
return value.longValue();
}
-
/**
* Returns the object pool associated with the given PoolKey.
*
@@ -550,7 +553,7 @@ public class PerUserPoolDataSource extends InstanceKeyDataSource {
throw new SQLException("RegisterPool failed", e);
}
}
- pool = ((CPDSConnectionFactory) manager).getPool();
+ pool = getCPDSConnectionFactoryPool(manager);
}
PooledConnectionAndInfo info = null;