[jOOQ/jOOQ#17094] R2DBC Connection leak when cancelling pending connection with ConnectionPool

Changes from the PR:
- Naming
- Avoid overriding concrete methods and use template pattern instead
- Add issue references to comments
This commit is contained in:
Lukas Eder 2024-09-23 17:36:46 +02:00
parent b32ac525fd
commit cb5e14e601

View File

@ -196,8 +196,12 @@ final class R2DBC {
}
@Override
public void cancel() {
complete(() -> {});
public final void cancel() {
complete(onCancel());
}
/* non-final */ Runnable onCancel() {
return () -> {};
}
final boolean moreRequested() {
@ -402,7 +406,8 @@ final class R2DBC {
@Override
public final void onSubscribe(Subscription s) {
// Stores the Subscription that handles the connection establishment.
// [#17094] Stores the Subscription that handles the connection establishment.
subscription.set(s);
s.request(1);
}
@ -423,9 +428,11 @@ final class R2DBC {
@Override
public final void onComplete() {}
public final void cancel() {
final void cancelSubscription() {
subscription.updateAndGet(s -> {
if (s != null) { s.cancel(); }
if (s != null)
s.cancel();
return null;
});
}
@ -664,9 +671,10 @@ final class R2DBC {
}
@Override
public final void cancel() {
// Safely cancels the connection acquisition if not yet established.
complete(() -> delegate().cancel());
final Runnable onCancel() {
// [#17094] Safely cancels the connection acquisition if not yet established.
return () -> delegate().cancelSubscription();
}
@Override