Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sinks.One<Void>.tryEmitValue no longer accepts null in 3.4.25/3.5.0 #3284

Closed
programmatix opened this issue Nov 16, 2022 · 5 comments
Closed
Assignees
Labels
status/has-workaround This has a known workaround described type/bug A general bug warn/regression A regression from a previous release
Milestone

Comments

@programmatix
Copy link

Calling tryEmitValue(null) on a Sinks.One<Void> worked without issue in 3.4.24, but in 3.5.0, we can see a NPE:

java.lang.NullPointerException: e
               at java.base/java.util.Objects.requireNonNull(Objects.java:233)
               at reactor.util.concurrent.SpscArrayQueue.offer(SpscArrayQueue.java:51)
               at reactor.core.publisher.FluxPublishOn$PublishOnSubscriber.onNext(FluxPublishOn.java:230)
               at reactor.core.publisher.SerializedSubscriber.onNext(SerializedSubscriber.java:99)
               at reactor.core.publisher.FluxTimeout$TimeoutMainSubscriber.onNext(FluxTimeout.java:180)
               at reactor.core.publisher.FluxFlatMap$FlatMapMain.tryEmit(FluxFlatMap.java:543)
               at reactor.core.publisher.FluxFlatMap$FlatMapInner.onNext(FluxFlatMap.java:984)
               at reactor.core.publisher.Operators$MonoInnerProducerBase.complete(Operators.java:2744)
               at reactor.core.publisher.SinkOneMulticast.tryEmitValue(SinkOneMulticast.java:63)
               at reactor.core.publisher.SinkOneSerialized.tryEmitValue(SinkOneSerialized.java:38)
               at com.couchbase.client.core.transaction.util.ReactiveWaitGroup.lambda$done$1(ReactiveWaitGroup.java:99)

The Javadocs for tryEmitValue still indicate that null is a legitimate value:

Params:
value – the value to emit and complete with, or null to only trigger an onComplete

EmitResult tryEmitValue(@Nullable T value);

The important change may have been in SinkOneMulticast.tryEmitValue. in 3.4.24 this has special handling for null:

		if (value == null) {
			for (Inner<O> as : array) {
				as.complete();
			}
		}

while in 3.5.0 it doesn't, it just passes the null through:

		for (Inner<O> as : prevSubscribers) {
			as.complete(value);
		}

I can't find any mention of this change in the release notes, and it's a breaking one for us. Can you please confirm if this is intentional or a bug, e.g. do I need to patch our code?

@reactorbot reactorbot added the ❓need-triage This issue needs triage, hasn't been looked at by a team member yet label Nov 16, 2022
@OlegDokuka OlegDokuka added warn/regression A regression from a previous release and removed ❓need-triage This issue needs triage, hasn't been looked at by a team member yet labels Nov 16, 2022
@OlegDokuka OlegDokuka added this to the 3.5.1 milestone Nov 16, 2022
@mikereiche
Copy link

This was working in 3.5.0-RC1 but is broken in 3.5.0. The change is 849be9a207958b111ee7a06f4b21596b0122972f.
Previously, if value was null, as.complete() was called with no argument.

Screen Shot 2022-11-16 at 11 59 47 AM

@simonbasle
Copy link
Member

this is actually a regression introduced in the 3.4.x branch (even though 3.4.25 was exceptionally released after 3.5.0).
re-targeting this for 3.4.26, which will be forward-merged to 3.5.1 as well

@simonbasle simonbasle modified the milestones: 3.5.1, 3.4.26 Nov 17, 2022
@simonbasle simonbasle self-assigned this Nov 17, 2022
@simonbasle simonbasle added the type/bug A general bug label Nov 17, 2022
@simonbasle simonbasle linked a pull request Nov 17, 2022 that will close this issue
@simonbasle
Copy link
Member

Regression introduced in #3260

@simonbasle simonbasle changed the title Sinks.One<Void>.tryEmitValue no longer accepts null in 3.5.0 Sinks.One<Void>.tryEmitValue no longer accepts null in 3.4.25/3.5.0 Nov 17, 2022
@simonbasle simonbasle added the status/has-workaround This has a known workaround described label Nov 17, 2022
@simonbasle
Copy link
Member

simonbasle commented Nov 17, 2022

simplest workaround:

T value;
EmitResult er = (value == null) ? sink.tryEmitEmpty() : sink.tryEmitValue(value);

@dnault
Copy link

dnault commented Nov 17, 2022

Thank you for jumping on this so quickly, @simonbasle

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/has-workaround This has a known workaround described type/bug A general bug warn/regression A regression from a previous release
Projects
None yet
Development

No branches or pull requests

6 participants