Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PooledConnection.close violates io.r2dbc.spi.Closeable contract by not being idempotent #221

Open
SanjayVas opened this issue Dec 18, 2024 · 0 comments

Comments

@SanjayVas
Copy link

SanjayVas commented Dec 18, 2024

Bug Report

Versions

N/A: Library issue at HEAD and in latest release (v1.0.2.RELEASE)

Current Behavior

Calling close() on a PooledConnection object that is already closed throws an IllegalStateException.

This method is overridden from the io.r2dbc.spi.Closeable interface, which states

If the object is already closed, then {@link Publisher#subscribe(Subscriber) subscriptions} complete successfully and the close operation has no effect.

Stack trace
java.lang.IllegalStateException: The connection is closed
    at io.r2dbc.pool.PooledConnection.assertNotClosed(PooledConnection.java:208)
    at io.r2dbc.pool.PooledConnection.close(PooledConnection.java:110)
    at io.r2dbc.pool.PooledConnection.close(PooledConnection.java:44)

Steps to reproduce

val connection: Connection = getPooledConnection()
connection.close().awaitFirstOrNull()
connection.close()  // Throws IllegalStateException

Expected behavior/code

No exception is thrown by close() if the Connection is already closed.
`

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

No branches or pull requests

1 participant