You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Gary D. Gregory (Jira)" <ji...@apache.org> on 2024/02/13 20:42:00 UTC

[jira] [Comment Edited] (DBCP-596) PoolingConnection.toString() causes StackOverflowError

    [ https://issues.apache.org/jira/browse/DBCP-596?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17817012#comment-17817012 ] 

Gary D. Gregory edited comment on DBCP-596 at 2/13/24 8:41 PM:
---------------------------------------------------------------

[~aapo.haapanen] 

Thank you for your report.

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]

Please report if you encounter SO's in other classes with this build.

I'd like to cut a release candidate to push this out if I hear all is well.


was (Author: garydgregory):
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)