CAMEL-24045: camel-sql - Fix connection leak with outputType=StreamList (backport to 4.18.x)#24810
Merged
Merged
Conversation
…st when the statement is not a query
gnodet
approved these changes
Jul 16, 2026
gnodet
left a comment
Contributor
There was a problem hiding this comment.
LGTM — clean backport of #24656 to 4.18.x.
The else branch in processStreamList() correctly closes the statement and connection
when ps.execute() returns false (non-query statement). Without it, the connection was
never returned to the pool since ResultSetIteratorCompletion was only registered for
query results. Also correctly sets the SQL_UPDATE_COUNT header for consistency with
processInternal().
The ConnectionCountingDataSource test wrapper using JDK Proxy is a nice approach — tracks
open/close atomically and asserts zero open connections after the exchange completes.
Note: test correctly uses junit5 import for the 4.18.x branch (vs junit6 on main).
Claude Code on behalf of gnodet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #24656 to
camel-4.18.x.JIRA: https://issues.apache.org/jira/browse/CAMEL-24045
SqlProducer.processStreamList()takes a raw connection from the DataSource so the result set can stay open while the exchange is routed. WhenPreparedStatement.execute()returnsfalse(INSERT/UPDATE/DELETE/DDL), the result-set branch was skipped: noResultSetIteratorCompletionwas registered and neither the connection nor the statement was ever closed — the catch block only cleaned up on exception. Since the executed SQL can vary per exchange via theCamelSqlQueryheader oruseMessageBodyForSql=true, each such exchange leaked one pooled connection, eventually exhausting the pool.Changes:
CamelSqlUpdateCountheader fromgetUpdateCount()for the non-query case, consistent with the non-query path inprocessInternal()camel-4.18.x(junit5package instead ofjunit6)Claude Code on behalf of Croway
🤖 Generated with Claude Code