Skip to content

Trying to fix flaky test #2779

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

Merged
merged 4 commits into from
Oct 21, 2021
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 @@ -25,8 +25,8 @@
public class BufferingSubscriber<T> implements Subscriber<T> {
private final CountDownLatch latch = new CountDownLatch(1);
private final List<T> bufferedItems = new ArrayList<>();
private Throwable bufferedError = null;
private boolean isCompleted = false;
Comment on lines -28 to -29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not entirely sure this is necessary since waitForCompletion should cause a sync but if it's working, it's not hurting anything I guess....

private volatile Throwable bufferedError = null;
private volatile boolean isCompleted = false;

@Override
public void onSubscribe(Subscription subscription) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ protected DynamoDbAsyncClient getDynamoDbAsyncClient() {
public static <T> List<T> drainPublisher(SdkPublisher<T> publisher, int expectedNumberOfResults) {
BufferingSubscriber<T> subscriber = new BufferingSubscriber<>();
publisher.subscribe(subscriber);
subscriber.waitForCompletion(1000L);
subscriber.waitForCompletion(5000L);

assertThat(subscriber.isCompleted(), is(true));
assertThat(subscriber.bufferedError(), is(nullValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.github.tomakehurst.wiremock.junit.WireMockRule;
import java.net.URI;
import java.util.List;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
Expand Down Expand Up @@ -71,6 +72,11 @@ public void setup() {
table = enhancedClient.table("table", tableSchema);
}

@After
public void cleanup() {
wireMock.resetAll();
}

@Test
public void successfulResponseWithoutUnprocessedKeys_NoNextPage() {
stubSuccessfulResponse();
Expand Down