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

Fix onErrorDropped logged message #1281

Merged
merged 1 commit into from
Jan 3, 2024
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 @@ -87,29 +87,28 @@ private void recurseCursor(){
batchCursor.setBatchSize(calculateBatchSize(sink.requestedFromDownstream()));
Mono.from(batchCursor.next(() -> sink.isCancelled()))
.doOnCancel(this::closeCursor)
.doOnError((e) -> {
try {
closeCursor();
} finally {
sink.error(e);
}
})
.doOnSuccess(results -> {
if (!results.isEmpty()) {
results
.stream()
.filter(Objects::nonNull)
.forEach(sink::next);
calculateDemand(-results.size());
}
if (batchCursor.isClosed()) {
sink.complete();
} else {
inProgress.set(false);
recurseCursor();
}
})
.subscribe();
.subscribe(results -> {
if (!results.isEmpty()) {
results
.stream()
.filter(Objects::nonNull)
.forEach(sink::next);
calculateDemand(-results.size());
}
if (batchCursor.isClosed()) {
sink.complete();
} else {
inProgress.set(false);
recurseCursor();
}
},
e -> {
try {
closeCursor();
} finally {
sink.error(e);
}
});
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@
import org.junit.After;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import reactor.core.publisher.Hooks;

import java.io.IOException;
import java.net.URISyntaxException;
import java.util.Collection;
import java.util.concurrent.atomic.AtomicReference;

import static com.mongodb.client.ClientSideOperationTimeoutTest.checkSkipCSOTTest;
import static com.mongodb.reactivestreams.client.syncadapter.SyncMongoClient.disableSleep;
Expand All @@ -42,6 +44,7 @@
@RunWith(Parameterized.class)
public class ClientSideOperationTimeoutTest extends UnifiedReactiveStreamsTest {
private final String testDescription;
private final AtomicReference<Throwable> atomicReferenceThrowable = new AtomicReference<>();

public ClientSideOperationTimeoutTest(final String fileDescription, final String testDescription,
final String schemaVersion, @Nullable final BsonArray runOnRequirements, final BsonArray entities,
Expand All @@ -58,13 +61,25 @@ public ClientSideOperationTimeoutTest(final String fileDescription, final String
if (testDescription.equals("timeoutMS is refreshed for close")) {
enableSleepAfterCursorError(256);
}

Hooks.onOperatorDebug();
Hooks.onErrorDropped(atomicReferenceThrowable::set);
}

@Parameterized.Parameters(name = "{0}: {1}")
public static Collection<Object[]> data() throws URISyntaxException, IOException {
return getTestData("unified-test-format/client-side-operation-timeout");
}

@Override
public void shouldPassAllOutcomes() {
super.shouldPassAllOutcomes();
Throwable droppedError = atomicReferenceThrowable.get();
if (droppedError != null) {
throw new AssertionError("Test passed but there was a dropped error; `onError` called with no handler.", droppedError);
}
}

@Override
protected MongoClient createMongoClient(final MongoClientSettings settings) {
TransportSettings overriddenTransportSettings = ClusterFixture.getOverriddenTransportSettings();
Expand All @@ -77,5 +92,7 @@ protected MongoClient createMongoClient(final MongoClientSettings settings) {
public void cleanUp() {
super.cleanUp();
disableSleep();
Hooks.resetOnOperatorDebug();
Hooks.resetOnErrorDropped();
}
}