Closed nicholashagen closed 3 weeks ago
Hello, @nicholashagen Thank you for the report and the reproducer! I am now looking into this issue and will update once I have some findings. At this point I can confirm this is a bug and needs addressing.
@nicholashagen #3914 aims to resolve the issue. I adapted your reproducer to make sure it always triggers the problem and also added a validation that the upstream subscription does not happen in such case.
The
MonoCacheInvalidateIf
operator (viacacheInvalidateIf
) can cause an NPE when subscriptions occur after a cancellation. This can lead the class in a broken state potentially.Expected Behavior
Cancellations should not cause an NPE and the flow should fail/cancel as expected.
Actual Behavior
An NPE is thrown until handled by an error operator.
Steps to Reproduce
Possible Solution
In the
remove
function,this.upstream.cancel()
is invoked. When a subscription occurs it callsonSubscribe
which sets theUPSTREAM
to the current subscription. However, ifcancel
is invoked, thenremove
is called and if the subscribe never happened in time, then it would benull
. Also, I'm not sure ifupstream
field should be used directly versus doing aget
on theUPSTREAM
atomic instance.Your Environment
Java 17, Mac OS, Junit 5
Reactor version(s) used:
reactor-core 3.6.10
Other relevant libraries versions (eg.
netty
, ...): N/AJVM version (
java -version
): 17OS and version (eg
uname -a
):