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

[#noissue] Fixed unstable test: FluxCommandResponseObserverTest #10438

Merged
merged 1 commit into from
Oct 30, 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
Expand Up @@ -97,7 +97,7 @@ public void onError(Throwable t) {
if (this.sink != null) {
this.sink.error(t);
} else {
logger.warn("Failed to emit error: sink not found");
logger.warn("Failed to emit error: sink not found. the error may have occurred before the first message");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@
import reactor.core.Disposable;
import reactor.core.publisher.Flux;
import reactor.core.publisher.FluxSink;
import reactor.core.publisher.Mono;

import java.time.Duration;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

Expand Down Expand Up @@ -56,9 +54,7 @@ public void testSuccessCase() {
AtomicInteger counter = new AtomicInteger(0);
AtomicReference<FluxSink<Integer>> sinkRef = new AtomicReference<>();

Disposable disposable = Flux.<Integer>create(sink -> {
sinkRef.set(sink);
}).subscribe(v -> {
Disposable disposable = Flux.<Integer>create(sinkRef::set).subscribe(v -> {
latest.set(v);
counter.getAndIncrement();
});
Expand Down Expand Up @@ -91,7 +87,7 @@ public void testSuccessCase() {
@Test
public void testErrorAfterData() {
AtomicReference<FluxSink<Integer>> sinkRef = new AtomicReference<>();
Disposable disposable = Flux.<Integer>create(sink -> sinkRef.set(sink)).subscribe();
Disposable disposable = Flux.<Integer>create(sinkRef::set).subscribe();

doAnswer(inv -> sinkRef.get()).when(sinkRepository).get(eq(SINK_ID));
doNothing().when(connectionObserver).onNext(any());
Expand All @@ -110,7 +106,7 @@ public void testErrorAfterData() {
@Test
public void testErrorAfterHello() {
AtomicReference<FluxSink<Integer>> sinkRef = new AtomicReference<>();
Disposable disposable = Flux.<Integer>create(sink -> sinkRef.set(sink)).subscribe();
Disposable disposable = Flux.<Integer>create(sinkRef::set).subscribe();

doAnswer(inv -> sinkRef.get()).when(sinkRepository).get(eq(SINK_ID));
doNothing().when(connectionObserver).onCompleted();
Expand All @@ -126,7 +122,8 @@ public void testErrorAfterHello() {

@Test
public void testErrorAtVeryFirst() {
Disposable disposable = Flux.<Integer>create(sink -> {}).take(Duration.ofMillis(100)).subscribe();
AtomicReference<FluxSink<Integer>> sinkRef = new AtomicReference<>();
Disposable disposable = Flux.<Integer>create(sinkRef::set).subscribe();

doNothing().when(connectionObserver).onCompleted();

Expand All @@ -136,10 +133,6 @@ public void testErrorAtVeryFirst() {

verify(connectionObserver, times(1)).onCompleted();
assertThat(disposable.isDisposed()).isFalse();

Mono.delay(Duration.ofMillis(100)).block();

assertThat(disposable.isDisposed()).isTrue();
}

@Test
Expand Down
Loading