Skip to content

Commit ad97480

Browse files
committed
Update unknown content length check
The original assumption was brittle and missed some types. Make the assumption check simpler and less error prone.
1 parent e1425b6 commit ad97480

File tree

2 files changed

+30
-21
lines changed

2 files changed

+30
-21
lines changed

test/s3-tests/src/it/java/software/amazon/awssdk/services/s3/regression/upload/UploadAsyncRegressionTesting.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,9 @@ void putObject(UploadConfig config) throws Exception {
6464
|| config.getBucketType() == BucketType.MRAP,
6565
"Async payload signing doesn't work with Java based clients");
6666

67-
// For testing purposes, ContentProvider is Publisher<ByteBuffer> for async clients
68-
// Async java based clients don't currently support unknown content-length bodies
69-
Assumptions.assumeFalse(config.getBodyType() == BodyType.CONTENT_PROVIDER_NO_LENGTH
70-
|| config.getBodyType() == BodyType.INPUTSTREAM_NO_LENGTH,
71-
"Async Java based support unknown content length");
67+
// Async java based clients don't support unknown content-length bodies
68+
Assumptions.assumeTrue(config.getBodyType().isContentLengthAvailable(),
69+
"Async Java based does not support unknown content length");
7270

7371
LOG.info(() -> "Running UploadAsyncRegressionTesting putObject with config: " + config);
7472

test/s3-tests/src/it/java/software/amazon/awssdk/services/s3/regression/upload/UploadStreamingRegressionTesting.java

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -397,29 +397,40 @@ void performWriteIfNeeded(TestAsyncBody requestBody) throws IOException {
397397
}
398398

399399
protected enum BodyType {
400-
INPUTSTREAM_RESETABLE,
401-
INPUTSTREAM_NOT_RESETABLE,
402-
INPUTSTREAM_NO_LENGTH,
400+
INPUTSTREAM_RESETABLE(true),
401+
INPUTSTREAM_NOT_RESETABLE(true),
402+
INPUTSTREAM_NO_LENGTH(false),
403403

404-
STRING,
404+
STRING(true),
405405

406-
FILE,
406+
FILE(true),
407407

408-
CONTENT_PROVIDER_WITH_LENGTH,
408+
CONTENT_PROVIDER_WITH_LENGTH(true),
409409

410-
CONTENT_PROVIDER_NO_LENGTH,
410+
CONTENT_PROVIDER_NO_LENGTH(false),
411411

412-
BYTES,
413-
BYTE_BUFFER,
414-
REMAINING_BYTE_BUFFER,
412+
BYTES(true),
413+
BYTE_BUFFER(true),
414+
REMAINING_BYTE_BUFFER(true),
415415

416-
BUFFERS,
417-
BUFFERS_REMAINING,
416+
BUFFERS(true),
417+
BUFFERS_REMAINING(true),
418418

419-
BLOCKING_INPUT_STREAM,
420-
BLOCKING_OUTPUT_STREAM,
421-
BUFFERED_SPLITTABLE_KNOWN_CONTENT_LENGTH,
422-
BUFFERED_SPLITTABLE_UNKNOWN_CONTENT_LENGTH
419+
BLOCKING_INPUT_STREAM(true),
420+
BLOCKING_OUTPUT_STREAM(true),
421+
BUFFERED_SPLITTABLE_KNOWN_CONTENT_LENGTH(true),
422+
BUFFERED_SPLITTABLE_UNKNOWN_CONTENT_LENGTH(false)
423+
;
424+
425+
private final boolean contentLengthAvailable;
426+
427+
BodyType(boolean contentLengthAvailable) {
428+
this.contentLengthAvailable = contentLengthAvailable;
429+
}
430+
431+
public boolean isContentLengthAvailable() {
432+
return contentLengthAvailable;
433+
}
423434
}
424435

425436
protected enum ContentSize {

0 commit comments

Comments
 (0)