Why UniMemoize doesn't call cancel on currentUpstreamSubscription after remove last awaiters in MemoizedSubscription.cancel? #1830
Replies: 2 comments 2 replies
-
|
Memoization "caches" a result for all the future subscribers. The contract is that the first subscription triggers some action that eventually yields a result, and that result becomes memoized until invalidated, so it's a simple state machine. There's no guarantee that forwarding a cancellation will avoid receiving any value, as cancellation is never immediate. Do you have any test / reproducer where the proposed implementation solves any correctness or performance issue? |
Beta Was this translation helpful? Give feedback.
-
|
Also stumbled upon this behavior and this was unexpected and unintuitive.
@jponge is this statement documented somewhere? Leaving my test case for others strangers Uni<String> uni = Uni.createFrom().item("foo")
.onItem().delayIt().by(Duration.ofSeconds(3))
.log("upstreamUni")
// if this memoization removed - upstream subscription is cancelled successfully
.memoize().indefinitely();
Cancellable subscription = uni
.log("downstreamUni")
.subscribe().with(System.out::println);
Thread.sleep(Duration.ofSeconds(1));
subscription.cancel();
Thread.sleep(Duration.ofSeconds(10)); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, please help me to understand. why MemoizedSubscription have so simple cancel method.
In case when cancel remove LAST awaites and cachedResult still not filled better to cancel subscription on
currentUpstreamSubscription. This is important to stop emitters and cleanup resources in memoized uni.I try to implement same operator but with another MemoizedSubscription
In my case it works fine. I do something wrong? Is this changes useful and can be merged to 2.x version (it allows to remove copy paste 90% line of code)?
Beta Was this translation helpful? Give feedback.
All reactions