[
https://issues.apache.org/jira/browse/DBCP-590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17679153#comment-17679153
]
Gary D. Gregory commented on DBCP-590:
--------------------------------------
Would reimplementing the method as below make sense (all tests pass), or, is
there an implementation that would be cleaner that you can think of?
{code:java}
protected DataSource createDataSourceInstance() throws SQLException {
if (!getAbandonedUsageTracking()) {
final PoolingDataSource<PoolableConnection> pds = new
PoolingDataSource<>(connectionPool);
pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
return pds;
}
// Workaround for https://issues.apache.org/jira/browse/DBCP-590
final GenericObjectPool<PoolableConnection> connectionPool =
getConnectionPool();
final JdkProxySource<PoolableConnection> jdkProxySource = new
JdkProxySource<>(getClass().getClassLoader(), new Class[] { Connection.class });
final ProxiedObjectPool<PoolableConnection> proxiedConnectionPool = new
ProxiedObjectPool<>(connectionPool, jdkProxySource);
final PoolingDataSource<PoolableConnection> poolingDataSource = new
PoolingDataSource<>(proxiedConnectionPool);
poolingDataSource.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed());
return poolingDataSource;
}
{code}
> BasicDataSource#setAbandonedUsageTracking has no effect
> -------------------------------------------------------
>
> Key: DBCP-590
> URL: https://issues.apache.org/jira/browse/DBCP-590
> Project: Commons DBCP
> Issue Type: Bug
> Affects Versions: 2.9.0
> Reporter: Réda Housni Alaoui
> Priority: Major
>
> Passing {{true}} to {{BasicDataSource#setAbandonedUsageTracking(boolean
> usageTracking)}} has no effect because {{UsageTracking#use}} is never called.
> From what I found, {{usageTracking}} can only work if the object pool is of
> type {{ProxiedObjectPool}} . Alas, BasicDataSource enforces
> {{GenericObjectPool}} concrete type preventing us from overriding
> {{BasicDataSource#createObjectPool}} to return a {{ProxiedObjectPool}} .
> Is there something I missed or a workaround?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)