[jira] [Commented] (DBCP-590) BasicDataSource#setAbandonedUsageTracking has no effect
[ https://issues.apache.org/jira/browse/DBCP-590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17793767#comment-17793767 ] Réda Housni Alaoui commented on DBCP-590: - {quote}I will do some testing and analysis some time this week.{quote} [~psteitz], could you take a look at this issue? > 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)
[jira] [Commented] (DBCP-590) BasicDataSource#setAbandonedUsageTracking has no effect
[ https://issues.apache.org/jira/browse/DBCP-590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17681805#comment-17681805 ] Phil Steitz commented on DBCP-590: -- I will look more at this when I have a little more time, but I suspect this may be a regression due to the refactoring changes in 344234a758da62aa422f6f67c6e7b1f37329c9c0. IIRC, this functionality used to work. I would not recommend changing the datasource creation until we understand what is causing the problem. Could be I am wrong and it did not work before. I will do some testing and analysis some time this week. > 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)
[jira] [Commented] (DBCP-590) BasicDataSource#setAbandonedUsageTracking has no effect
[ https://issues.apache.org/jira/browse/DBCP-590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=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 pds = new PoolingDataSource<>(connectionPool); pds.setAccessToUnderlyingConnectionAllowed(isAccessToUnderlyingConnectionAllowed()); return pds; } // Workaround for https://issues.apache.org/jira/browse/DBCP-590 final GenericObjectPool connectionPool = getConnectionPool(); final JdkProxySource jdkProxySource = new JdkProxySource<>(getClass().getClassLoader(), new Class[] { Connection.class }); final ProxiedObjectPool proxiedConnectionPool = new ProxiedObjectPool<>(connectionPool, jdkProxySource); final PoolingDataSource 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)
[jira] [Commented] (DBCP-590) BasicDataSource#setAbandonedUsageTracking has no effect
[ https://issues.apache.org/jira/browse/DBCP-590?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel=17676588#comment-17676588 ] Réda Housni Alaoui commented on DBCP-590: - Here is my workaround for now: {code:java} import java.sql.Connection; import java.sql.SQLException; import javax.sql.DataSource; import org.apache.commons.dbcp2.BasicDataSource; import org.apache.commons.dbcp2.PoolableConnection; import org.apache.commons.dbcp2.PoolingDataSource; import org.apache.commons.pool2.impl.GenericObjectPool; import org.apache.commons.pool2.proxy.JdkProxySource; import org.apache.commons.pool2.proxy.ProxiedObjectPool; class ExtendedBasicDataSource extends BasicDataSource { @Override protected DataSource createDataSourceInstance() throws SQLException { if (!getAbandonedUsageTracking()) { return super.createDataSourceInstance(); } // Workaround for https://issues.apache.org/jira/browse/DBCP-590 GenericObjectPool connectionPool = getConnectionPool(); JdkProxySource jdkProxySource = new JdkProxySource<>(getClass().getClassLoader(), new Class[] {Connection.class}); ProxiedObjectPool proxiedConnectionPool = new ProxiedObjectPool<>(connectionPool, jdkProxySource); PoolingDataSource 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)