- 
                Notifications
    You must be signed in to change notification settings 
- Fork 38.8k
Closed as not planned
Labels
for: external-projectNeeds a fix in external projectNeeds a fix in external projectstatus: invalidAn issue that we don't feel is validAn issue that we don't feel is valid
Description
I encountered an unexpected behavior when using .take(1) in my Reactor Flux pipeline. Below is the code snippet I used:
Flux.just("", "b")
    .doOnEach(signal -> {
        System.out.println("signal " + signal);
    })
    .filter(StringUtils::isNotBlank)
    .map(e -> {
        System.out.println("map element " + e);
        return e;
    })
    .subscribe();Expected Behavior
Without .take(1), the output is as follows:
signal doOnEach_onNext()
signal doOnEach_onNext(b)
map element b
signal onComplete()
This behavior aligns with my expectations.
Unexpected Behavior
However, when I add .take(1), like this:
Flux.just("", "b")
    .doOnEach(signal -> {
        System.out.println("signal " + signal);
    })
    .filter(StringUtils::isNotBlank)
    .map(e -> {
        System.out.println("map element " + e);
        return e;
    })
    .take(1)
    .subscribe();The output changes to:
map element b
signal doOnEach_onNext(b)
This is different from the previous case, and I have two questions:
- Why does adding .take(1)change the behavior?
- Why does map element bappear beforesignal doOnEach_onNext(b)in the output?
I would appreciate any insights or explanations regarding this behavior. Thank you!
Metadata
Metadata
Assignees
Labels
for: external-projectNeeds a fix in external projectNeeds a fix in external projectstatus: invalidAn issue that we don't feel is validAn issue that we don't feel is valid