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

ensures empty inner handled properly in case of sync fusion #3329

Merged
merged 3 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2022 VMware Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2016-2023 VMware Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -588,7 +588,7 @@ void drainSync() {
sp = iterable.spliterator();
itFinite = FluxIterable.checkFinite(sp);

isEmpty = itFinite && sp.estimateSize() == 0;
isEmpty = itFinite ? sp.estimateSize() == 0 : !hasNext(sp);
}
catch (Throwable exc) {
resetCurrent();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2022 VMware Inc. or its affiliates, All Rights Reserved.
* Copyright (c) 2016-2023 VMware Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -705,6 +705,24 @@ public void testFluxIterableEmptyCase(Function<Flux, Flux> fn) {
.verify();
}

@ParameterizedTestWithName
@MethodSource("reactor.core.publisher.FluxIterableTest#factory")
public void testFluxIterableSyncFusionEmptyCase(Function<Flux, Flux> fn) {
Iterable<String> iterable = mock(Iterable.class);
Mockito.when(iterable.spliterator())
.thenReturn(mock(Spliterator.class));

StepVerifier.create(
Flux.just(1, 2)
.flatMapIterable(__ -> iterable)
.as(fn)
.next()
)
.expectSubscription()
.expectComplete()
.verify();
}

@ParameterizedTestWithName
@MethodSource("reactor.core.publisher.FluxIterableTest#factory")
public void testFluxIterableErrorHasNext(Function<Flux, Flux> fn) {
Expand Down