[
https://issues.apache.org/jira/browse/DBCP-596?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Gary D. Gregory resolved DBCP-596.
----------------------------------
Fix Version/s: 2.11.1
Resolution: Fixed
A fix is in git master and 2.11.1-SNAPSHOT builds in
[https://repository.apache.org/content/repositories/snapshots/org/apache/commons/commons-dbcp2]
> PoolingConnection.toString() causes StackOverflowError
> ------------------------------------------------------
>
> Key: DBCP-596
> URL: https://issues.apache.org/jira/browse/DBCP-596
> Project: Commons DBCP
> Issue Type: Bug
> Affects Versions: 2.11.0
> Reporter: Aapo Haapanen
> Assignee: Gary D. Gregory
> Priority: Major
> Fix For: 2.11.1
>
>
> {{{}PoolingConnection{}}}, as it is constructed by
> {{PoolableConnectionFactory.makeObject()}} method, causes StackOverflowError
> in its {{toString()}} method.
> {{PoolingConnection}} acts as the object factory for the statement pool,
> while {{GenericKeyedObjectPool}} implements the statement pool.
> {{PoolingConnection.toString()}} calls the pool's {{toString()}} method,
> while {{GenericKeyedObjectPool.toStringAppendFields()}} calls the factory's
> {{{}toString(){}}}.
> Here is small test application that causes StackOverflowError:
> {code:java}
> import org.apache.commons.dbcp2.DelegatingPreparedStatement;
> import org.apache.commons.dbcp2.PoolingConnection;
> import org.apache.commons.pool2.impl.GenericKeyedObjectPool;
> import org.apache.commons.pool2.impl.GenericKeyedObjectPoolConfig;
> public class Main {
> public static void main(String[] args) {
> final var conn = new PoolingConnection(null);
> final var config = new
> GenericKeyedObjectPoolConfig<DelegatingPreparedStatement>();
> final var stmtPool = new GenericKeyedObjectPool<>(conn, config);
> conn.setStatementPool(stmtPool);
> conn.toString();
> }
> } {code}
> In normal use cases this doesn't cause a problem, but we've encountered this
> bug in some situations with network connectivity problems.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)