Skip to content

Commit add089a

Browse files
committed
Add retry
1 parent a6c51c5 commit add089a

File tree

1 file changed

+30
-22
lines changed

1 file changed

+30
-22
lines changed

services/s3/src/test/java/software/amazon/awssdk/services/s3/internal/multipart/S3MultipartClientPutObjectWiremockTest.java

Lines changed: 30 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import software.amazon.awssdk.services.s3.S3AsyncClient;
6363
import software.amazon.awssdk.services.s3.model.PutObjectResponse;
6464
import software.amazon.awssdk.services.s3.model.S3Exception;
65+
import software.amazon.awssdk.testutils.retry.RetryableTest;
6566

6667
@WireMockTest
6768
@Timeout(120)
@@ -177,29 +178,36 @@ public void subscribe(Subscriber<? super ByteBuffer> s) {
177178
void mpuDefaultSplitImpl_partsFailOfRetryableError_shouldFail(String description,
178179
Long contentLength,
179180
ResponseDefinitionBuilder responseDefinitionBuilder) {
180-
stubUploadPartFailsInitialAttemptSucceedsUponRetryCalls(responseDefinitionBuilder);
181-
List<ByteBuffer> buffers = new ArrayList<>();
182-
buffers.add(SdkBytes.fromUtf8String(RandomStringUtils.randomAscii(10)).asByteBuffer());
183-
buffers.add(SdkBytes.fromUtf8String(RandomStringUtils.randomAscii(10)).asByteBuffer());
184-
AsyncRequestBody asyncRequestBody = new AsyncRequestBody() {
185-
@Override
186-
public Optional<Long> contentLength() {
187-
return Optional.ofNullable(contentLength);
181+
for (int i = 0; i < 3; i++) {
182+
try {
183+
stubUploadPartFailsInitialAttemptSucceedsUponRetryCalls(responseDefinitionBuilder);
184+
List<ByteBuffer> buffers = new ArrayList<>();
185+
buffers.add(SdkBytes.fromUtf8String(RandomStringUtils.randomAscii(10)).asByteBuffer());
186+
buffers.add(SdkBytes.fromUtf8String(RandomStringUtils.randomAscii(10)).asByteBuffer());
187+
AsyncRequestBody asyncRequestBody = new AsyncRequestBody() {
188+
@Override
189+
public Optional<Long> contentLength() {
190+
return Optional.ofNullable(contentLength);
191+
}
192+
193+
@Override
194+
public void subscribe(Subscriber<? super ByteBuffer> s) {
195+
Flowable.fromIterable(buffers).subscribe(s);
196+
}
197+
};
198+
199+
assertThatThrownBy(() -> s3AsyncClient.putObject(b -> b.bucket(BUCKET).key(KEY), asyncRequestBody)
200+
.join())
201+
.hasCauseInstanceOf(NonRetryableException.class)
202+
.hasMessageContaining("Multiple subscribers detected.");
203+
204+
verify(1, putRequestedFor(anyUrl()).withQueryParam("partNumber", matching(String.valueOf(1))));
205+
verify(1, putRequestedFor(anyUrl()).withQueryParam("partNumber", matching(String.valueOf(1))));
206+
return;
207+
} catch (AssertionError e) {
208+
if (i == 2) throw e;
188209
}
189-
190-
@Override
191-
public void subscribe(Subscriber<? super ByteBuffer> s) {
192-
Flowable.fromIterable(buffers).subscribe(s);
193-
}
194-
};
195-
196-
assertThatThrownBy(() -> s3AsyncClient.putObject(b -> b.bucket(BUCKET).key(KEY), asyncRequestBody)
197-
.join())
198-
.hasCauseInstanceOf(NonRetryableException.class)
199-
.hasMessageContaining("Multiple subscribers detected.");
200-
201-
verify(1, putRequestedFor(anyUrl()).withQueryParam("partNumber", matching(String.valueOf(1))));
202-
verify(1, putRequestedFor(anyUrl()).withQueryParam("partNumber", matching(String.valueOf(1))));
210+
}
203211
}
204212

205213

0 commit comments

Comments
 (0)