Skip to content

Commit de77ae5

Browse files
authored
Trying to fix flaky test (#2779)
* Fix flaky test * Increase completion wait time * Add volatile
1 parent 84a905c commit de77ae5

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/BufferingSubscriber.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@
2525
public class BufferingSubscriber<T> implements Subscriber<T> {
2626
private final CountDownLatch latch = new CountDownLatch(1);
2727
private final List<T> bufferedItems = new ArrayList<>();
28-
private Throwable bufferedError = null;
29-
private boolean isCompleted = false;
28+
private volatile Throwable bufferedError = null;
29+
private volatile boolean isCompleted = false;
3030

3131
@Override
3232
public void onSubscribe(Subscription subscription) {

services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/functionaltests/LocalDynamoDbAsyncTestBase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ protected DynamoDbAsyncClient getDynamoDbAsyncClient() {
3232
public static <T> List<T> drainPublisher(SdkPublisher<T> publisher, int expectedNumberOfResults) {
3333
BufferingSubscriber<T> subscriber = new BufferingSubscriber<>();
3434
publisher.subscribe(subscriber);
35-
subscriber.waitForCompletion(1000L);
35+
subscriber.waitForCompletion(5000L);
3636

3737
assertThat(subscriber.isCompleted(), is(true));
3838
assertThat(subscriber.bufferedError(), is(nullValue()));

services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/mocktests/AsyncBatchGetItemTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.github.tomakehurst.wiremock.junit.WireMockRule;
2525
import java.net.URI;
2626
import java.util.List;
27+
import org.junit.After;
2728
import org.junit.Before;
2829
import org.junit.Rule;
2930
import org.junit.Test;
@@ -71,6 +72,11 @@ public void setup() {
7172
table = enhancedClient.table("table", tableSchema);
7273
}
7374

75+
@After
76+
public void cleanup() {
77+
wireMock.resetAll();
78+
}
79+
7480
@Test
7581
public void successfulResponseWithoutUnprocessedKeys_NoNextPage() {
7682
stubSuccessfulResponse();

0 commit comments

Comments
 (0)