Bug 63995 - Statements are not closed when a JDBC connection is passivated in tomcat-dbcp
Summary: Statements are not closed when a JDBC connection is passivated in tomcat-dbcp
Alias: None
Product: Tomcat 8
Classification: Unclassified
Component: Catalina (show other bugs)
Version: 8.5.49
Hardware: PC All
: P2 normal (vote)
Target Milestone: ----
Assignee: Tomcat Developers Mailing List
Depends on:
Reported: 2019-12-09 15:22 UTC by Sergey Stremin
Modified: 2019-12-10 10:54 UTC (History)
0 users


Note You need to log in before you can comment on or make changes to this bug.
Description Sergey Stremin 2019-12-09 15:22:30 UTC
Web-application opens connection from JNDI pool, creates PreparedStatements, closes connection without closing statements.

Statements are kept open and 
"ORA-01000: maximum open cursors exceeded" error is thrown.

Pool is expected to close statements on connection close.

The problem seems to be in src/main/java/org/apache/commons/dbcp2/DelegatingConnection.java, ported from DBCP2.

Tomcat version (but not dbcp2 version) contains following code:

    protected void passivate() throws SQLException {
        if (traces != null && traces.isEmpty()) {

In DBCP2 version this line has ! before isEmpty():

        if (traces != null && !traces.isEmpty()) {
Comment 1 Mark Thomas 2019-12-10 10:54:24 UTC
Thanks for the report and the analysis. I did a line by line diff of the entire fork and found one additional issue as well.

Fixed in:
- master for 9.0.31 onwards
- 8.5.x for 8.5.51 onwards