You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Release connection on reactive beginTransaction cancellation
Each transaction created by the driver requires a network connection. Unfinished transactions may result in connection leaks, meaning that connections acquired from the connection pool are not available for further use.
Subscription cancellation on reactive `beginTransaction` during transaction creation could result in dangling transaction, leading to the connection leak. This update fixes this issue by ensuring that such transactions are rolled back and their connections are returned to the connection pool.
Copy file name to clipboardExpand all lines: driver/src/main/java/org/neo4j/driver/internal/reactive/RxUtils.java
+73-13Lines changed: 73 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -18,8 +18,11 @@
18
18
*/
19
19
packageorg.neo4j.driver.internal.reactive;
20
20
21
+
importstaticjava.util.Objects.requireNonNull;
22
+
21
23
importjava.util.Optional;
22
24
importjava.util.concurrent.CompletionStage;
25
+
importjava.util.function.Consumer;
23
26
importjava.util.function.Supplier;
24
27
importorg.neo4j.driver.internal.util.Futures;
25
28
importorg.reactivestreams.Publisher;
@@ -28,6 +31,7 @@
28
31
publicclassRxUtils {
29
32
/**
30
33
* The publisher created by this method will either succeed without publishing anything or fail with an error.
34
+
*
31
35
* @param supplier supplies a {@link CompletionStage<Void>}.
32
36
* @return A publisher that publishes nothing on completion or fails with an error.
33
37
*/
@@ -48,23 +52,79 @@ public static <T> Publisher<T> createEmptyPublisher(Supplier<CompletionStage<Voi
48
52
* @param supplier supplies a {@link CompletionStage<T>} that MUST produce a non-null result when completed successfully.
49
53
* @param nullResultThrowableSupplier supplies a {@link Throwable} that is used as an error when the supplied completion stage completes successfully with
50
54
* null.
55
+
* @param cancellationHandler handles cancellation, may be used to release associated resources
51
56
* @param <T> the type of the item to publish.
52
57
* @return A publisher that succeeds exactly one item or fails with an error.
0 commit comments