[jOOQ/jOOQ#12977] Correctly sequence close() call and completion delegation

This commit is contained in:
Lukas Eder 2022-02-09 16:26:10 +01:00
parent 00fcb99d83
commit fe9e8854ea
2 changed files with 11 additions and 4 deletions

View File

@ -583,16 +583,18 @@ final class R2DBC {
delegate().connection.updateAndGet(c -> {
// [#12977] Correctly sequence the delegation to run after close completion
Runnable onComplete = cancelled ? () -> {} : () -> subscriber.onComplete();
// close() calls on already closed resources have no effect, so
// the side-effect is OK with the AtomicReference contract
if (c != null)
c.close().subscribe(subscriber(s -> s.request(Long.MAX_VALUE), t -> {}, t -> {}, () -> {}));
c.close().subscribe(subscriber(s -> s.request(Long.MAX_VALUE), t -> {}, t -> {}, onComplete));
else
onComplete.run();
return null;
});
if (!cancelled)
subscriber.onComplete();
}
abstract ConnectionSubscriber<T> delegate();

View File

@ -457,6 +457,11 @@
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-r2dbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>