Skip to content

Prevent connection pool exhaustion when a borrow listener throws - #168

Open
foc-nico wants to merge 1 commit into
ebean-orm:mainfrom
FOCONIS:fix/borrow-listener-pool-exhaustion
Open

foc-nico wants to merge 1 commit into
ebean-orm:mainfrom
FOCONIS:fix/borrow-listener-pool-exhaustion

Conversation

@foc-nico

Copy link
Copy Markdown

Motivation

onAfterBorrowConnection() runs after the pool checks out a connection but before getConnection() hands it to the caller. If the listener throws, the caller never receives the connection and cannot close it. The connection stays checked out, so repeated listener failures can exhaust the pool and block otherwise healthy requests.

This change closes the borrowed connection on the failure path and rethrows the original error. If cleanup also fails, that failure is attached as a suppressed exception. The successful borrow path and the public API are unchanged.

Port the ConnectionPool change from ce37cd8 to the existing borrow listener API.
@foc-nico
foc-nico marked this pull request as ready for review November 20, 2026 13:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant