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
takeUntil(Predicate) tests after element has been emitted #3539
Comments
@AramMessdaghi9001 Did you try to use takeWhile? It does exactly what you need. Also, it is untipattern to rely on something mutable as well as mutating something. The overall recomendation is to make a slice of a buffer (or a copy) and work on it instead of the original one |
@OlegDokuka takeWhile is exclusive. I want the operator to be inclusive. By the way, this is no question for stack overflow, but a bug report due to unexpected behavior. |
I guess we can enhance the implementation so it sends after predicate is executed |
takeUntil(Predicate) executes the predicate test after the element has been emitted.
If the element is mutable and modified afterwards, this changes the behavior in an unexpected way.
Expected Behavior
The predicate test should be executed before the element has been emitted, not after it has been emitted.
Of course it should still be emitted when the predicate test returns false, in order to match the requirement.
Actual Behavior
The predicate test is executed after the element has been consumed and possibly been modified by following publishers.
Steps to Reproduce
This is a simplified version
Here is a more complex scenario:
Consuming the Flux will not read the file to the end, as
remaining
will be 0 at time of the predicate test, due to being read already by the consuming FluxPossible Solution
Execute the predicate.test in FluxTakeUntil before actual.onNext
Your Environment
The text was updated successfully, but these errors were encountered: