You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Justin Cranford (JIRA)" <ji...@apache.org> on 2015/07/17 07:17:04 UTC
[jira] [Updated] (POOL-299) testOnBorrow overrides
testOnCreate=false, add testOnReuse to compliment testOnCreate
[ https://issues.apache.org/jira/browse/POOL-299?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Justin Cranford updated POOL-299:
---------------------------------
Description:
I am using Commons DBCP 2.1 with Commons Pool 2.4. When borrowing a connection from DBCP, the underlying pool either reuses a connection or creates a new connection. Validation of that connection seems to be triggered in borrowObject() of GenericKeyedObjectPool or GenericObjectPool based on two settings passed from DBCP 2.1.
if (p != null && (getTestOnBorrow() || create && getTestOnCreate())) {
I would like to only validate reused connections, not new connections. Validating a new connection is redundant since successful creation implies it is valid. Commons Pools 2 does not allow me to only validate reused connections, though. If I set testOnBorrow=true, then Commons Pool 2 validates new or reused connections, and testOnCreate is effectively overridden. If I set testOnBorrow=false, then my only option to set testOnCreate=true does not match what I need.
I would like to offer a possible solution. If Commons Pool 2 were to add a new setting called testOnReuse, it would compliment testOnCreate like so:
> if (p != null && ((getTestOnBorrow()) || (!create && getTestOnReuse()) || (create && getTestOnCreate()))) {
This solutions allows testOnBorrow to be backwards compatible. It validates new or reused objects, and it overrides testOnCreate (and testOnReuse). However, now I have the option to only validate reused connections, and not new connections.
- testOnBorrow=false
- testOnCreate=false
- testOnReuse=true
Adding testOnReuse would be ideal. It would have the same default value as testOnCreate. If it could be added to Commons Pool 2, then I could open an enhancement ticket in Commons DBCP 2 to expose it in the API and config. Any other project depending on Commons Pool 2 could also take advantage of the new option.
was:
I am using Commons DBCP 2.1 with Commons Pool 2.4. When borrowing a connection from DBCP, the underlying pool either reuses a connection or creates a new connection. Validation of that connection seems to be triggered in borrowObject() of GenericKeyedObjectPool or GenericObjectPool based on two settings passed from DBCP 2.1.
if (p != null && (getTestOnBorrow() || create && getTestOnCreate())) {
I would like to only validate reused connections, not new connections. Validating a new connection is redundant since successful creation implies it is valid. Commons Pools 2 does not allowing me to only validate reused connections, though. If I set testOnBorrow=true then Commons Pool 2 validates new or reused connections, and testOnCreate is effectively overridden. If I set testOnBorrow=false, then my only option to set testOnCreate=true which is also not what I need.
I would like to offer a possible solution. If Commons Pool 2 were to add a new setting called testOnReuse, it would compliment testOnCreate like so:
> if (p != null && ((getTestOnBorrow()) || (!create && getTestOnReuse()) || (create && getTestOnCreate()))) {
This solutions allows testOnBorrow to be backwards compatible. It validates new or reused objects, and it overrides testOnCreate (and testOnReuse). However, now I have the option to only validate reused connections, and not new connections.
- testOnBorrow=false
- testOnCreate=false
- testOnReuse=true
Adding testOnReuse would be ideal. It would have the same default value as testOnCreate. If it could be added to Commons Pool 2, then it can be added to Commons DBCP 2 later, or any other project depending on Commons Pool 2.
> testOnBorrow overrides testOnCreate=false, add testOnReuse to compliment testOnCreate
> -------------------------------------------------------------------------------------
>
> Key: POOL-299
> URL: https://issues.apache.org/jira/browse/POOL-299
> Project: Commons Pool
> Issue Type: Bug
> Affects Versions: 2.4
> Environment: DBCP 2.1.0 with Commons Pool 2.4.0
> Reporter: Justin Cranford
> Priority: Minor
> Labels: performance
>
> I am using Commons DBCP 2.1 with Commons Pool 2.4. When borrowing a connection from DBCP, the underlying pool either reuses a connection or creates a new connection. Validation of that connection seems to be triggered in borrowObject() of GenericKeyedObjectPool or GenericObjectPool based on two settings passed from DBCP 2.1.
> if (p != null && (getTestOnBorrow() || create && getTestOnCreate())) {
> I would like to only validate reused connections, not new connections. Validating a new connection is redundant since successful creation implies it is valid. Commons Pools 2 does not allow me to only validate reused connections, though. If I set testOnBorrow=true, then Commons Pool 2 validates new or reused connections, and testOnCreate is effectively overridden. If I set testOnBorrow=false, then my only option to set testOnCreate=true does not match what I need.
> I would like to offer a possible solution. If Commons Pool 2 were to add a new setting called testOnReuse, it would compliment testOnCreate like so:
> > if (p != null && ((getTestOnBorrow()) || (!create && getTestOnReuse()) || (create && getTestOnCreate()))) {
> This solutions allows testOnBorrow to be backwards compatible. It validates new or reused objects, and it overrides testOnCreate (and testOnReuse). However, now I have the option to only validate reused connections, and not new connections.
> - testOnBorrow=false
> - testOnCreate=false
> - testOnReuse=true
> Adding testOnReuse would be ideal. It would have the same default value as testOnCreate. If it could be added to Commons Pool 2, then I could open an enhancement ticket in Commons DBCP 2 to expose it in the API and config. Any other project depending on Commons Pool 2 could also take advantage of the new option.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)