Skip to content

Add discard support to Mono.sequenceEqual - #4381

Open
hunseonglee wants to merge 1 commit into
reactor:mainfrom
hunseonglee:bughunt/sequenceequal-discard
Open

hunseonglee wants to merge 1 commit into
reactor:mainfrom
hunseonglee:bughunt/sequenceequal-discard

Conversation

@hunseonglee

Copy link
Copy Markdown

MonoSequenceEqual cleared both inner queues with a plain queue.clear() and silently dropped the held-but-uncompared v1/v2 values on downstream cancel, source error, comparer throw, and the inequality short-circuit — no Operators.onDiscard* anywhere in the operator.

This change introduces discardCurrentValuesAndQueues() (discarding v1, v2 and both queues via Operators.onDiscard/onDiscardQueueWithClear), invoked from cancel() under the WIP guard, from the drain-loop cancelled branch, and from the internal terminal path. Discard Support javadoc added to all three Mono.sequenceEqual overloads.

Two regression tests added (discardOnCancel, discardOnMismatch) — both fail on main with empty discard collections and pass with the fix; MonoSequenceEqualTest passes 23/23.

Fixes #4378

The operator buffers elements from both sources but cleared its queues
without invoking the discard hook on cancellation, on error, when the
comparison found a difference, and for the value held while waiting for
the other source. Buffered and held elements are now passed to
Operators.onDiscard, and the discard behavior is documented on the
sequenceEqual javadoc.

Signed-off-by: seonghun lee <harrisleesh@gmail.com>
@hunseonglee
hunseonglee requested a review from a team as a code owner September 3, 2026 13:58

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Mono.sequenceEqual does not discard buffered elements on cancellation, error, or mismatch

1 participant