rich7420 opened a new pull request, #10461:
URL: https://github.com/apache/ozone/pull/10461
## What changes were proposed in this pull request?
When a client completes a multipart upload using chunked transfer encoding
(no `Content-Length`, e.g. the AWS C++ SDK which sends the request with
`Expect: 100-continue`), Ozone S3 Gateway rejects the request with HTTP 400
`You must specify at least one part`, even though the request body does
contain the parts.
The root cause is in `CompleteMultipartUploadRequestUnmarshaller`, which used
`InputStream#available() == 0` to detect an empty request body. `available()`
only reports the number of bytes that can be read **without blocking**; for a
body that has not been buffered yet (chunked transfer / `Expect:
100-continue`)
it can legitimately return `0` even though the body is non-empty. As a result
the unmarshaller wrongly concluded the body was empty and raised the
"must specify at least one part" error before parsing the parts.
This PR replaces the unreliable `available()` check with a proper
empty-body detection: it wraps the stream in a `PushbackInputStream` and
reads
a single byte. `read()` blocks until data arrives or EOF is reached, so:
* if it returns `-1`, the body is genuinely empty and the original clean
error
is raised (preserving the behavior introduced in HDDS-11457);
* otherwise the byte is pushed back and parsing proceeds normally.
This is the only use of `InputStream#available()` in the S3 Gateway, so no
other request type is affected.
## What is the link to the Apache JIRA
https://issues.apache.org/jira/projects/HDDS/issues/HDDS-14760
## How was this patch tested?
* New unit tests in `TestCompleteMultipartUploadRequestUnmarshaller`:
* `fromStreamWhereAvailableReturnsZero` reproduces the bug using a stream
whose `available()` always returns `0` while the body holds valid parts.
It fails before the fix and passes after it.
* `emptyBodyThrowsMustSpecifyAtLeastOnePart` verifies the empty-body error
is still returned.
* Existing unmarshaller tests (with/without namespace, concurrent parsing)
and
the S3 Gateway multipart tests pass with no regression.
* Added an acceptance test `Test Multipart Upload Complete With Chunked
Transfer Encoding` in `MultipartUpload.robot` that completes an MPU
through a
presigned URL with `Transfer-Encoding: chunked` (no `Content-Length`),
exercising the end-to-end path that the C++ SDK triggers.
* CI run on the fork:
https://github.com/rich7420/ozone/actions/runs/27128059905
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]