Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
2.14.0
-
None
-
Linux, Apache Tomcat 7.0.41
-
Patch Available
-
Unknown
Description
When using camel-jdbc component with newly introduced StreamList mode I've faced a 100% reproducible connection leak issue.
My investigation leads me to Tomcat connection pool implementation - it has problem with returing current connection from Statement object - instead of returning pool specific proxy it returns actual JDBC connection.
There is `statement.getConnection()` line in `org.apache.camel.component.jdbc.ResultSetIterator` so in my particular scenario things work like this:
1) Camel borrows connection from Tomcat pool
2) Camel leaves JDBC connection and ResultSet intact as we use StreamList mode of camel-jdbc component
3) Route processes resultset in streaming mode and completes successfully
4) Camel tries to close connection, but due to connection pool implementation issue it closes actual JDBC connection instead of returing it to the pool
5) Actual JDBC connection is closed an connection pool is unaware of this fact thinking it's still open and in use by application
It would be more error prone to pass proper connection object to ResultSetIterator along with result set and not rely on statement.getConnection() call.