|
62 | 62 | import software.amazon.awssdk.services.s3.S3AsyncClient; |
63 | 63 | import software.amazon.awssdk.services.s3.model.PutObjectResponse; |
64 | 64 | import software.amazon.awssdk.services.s3.model.S3Exception; |
| 65 | +import software.amazon.awssdk.testutils.retry.RetryableTest; |
65 | 66 |
|
66 | 67 | @WireMockTest |
67 | 68 | @Timeout(120) |
@@ -177,29 +178,36 @@ public void subscribe(Subscriber<? super ByteBuffer> s) { |
177 | 178 | void mpuDefaultSplitImpl_partsFailOfRetryableError_shouldFail(String description, |
178 | 179 | Long contentLength, |
179 | 180 | 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; |
188 | 209 | } |
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 | + } |
203 | 211 | } |
204 | 212 |
|
205 | 213 |
|
|
0 commit comments