Skip to content

Fix PutObject with CRT client chunkedEncodingEnabled(false)#7129

Open
davidh44 wants to merge 6 commits into
masterfrom
hdavidh/fix-crt-s3-put-chunkedEncodingEnabled-false
Open

Fix PutObject with CRT client chunkedEncodingEnabled(false)#7129
davidh44 wants to merge 6 commits into
masterfrom
hdavidh/fix-crt-s3-put-chunkedEncodingEnabled-false

Conversation

@davidh44

@davidh44 davidh44 commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

S3 PutObject hangs indefinitely when using AwsCrtAsyncHttpClient with chunkedEncodingEnabled(false). Bug introduced in 2.30.0 when requestChecksumCalculation defaulted to WHEN_SUPPORTED, which triggers automatic checksum computation for PutObject. With chunked encoding disabled, the SDK buffers the payload into InMemoryPublisher to compute a header-based checksum. CRT's subscriber calls request(1) synchronously from within onNext() (legal per Reactive Streams spec), causing a re-entrant deadlock in InMemoryPublisher.fulfillDemand().

Modifications

Checksum computation (http-auth-aws)

  • FlexibleChecksummer — Replace detached thenRun with thenApply to guarantee checksum headers are set before signing proceeds. Theoretical race condition fix — prevents issues if the body source delivers asynchronously.
  • ChecksumSubscriber — Compute total buffered bytes in onComplete() and pass to InMemoryPublisher.
  • InMemoryPublisher — Fix re-entrant deadlock in fulfillDemand(): return immediately on re-entrant call instead of spinning; outer do-while re-checks demand after releasing for multi-threaded safety. Also implement SdkHttpContentPublisher to report contentLength().

Signing (sdk-core)

  • AsyncSigningStage — Preserve contentLength() when wrapping SdkHttpContentPublisher payload into AsyncRequestBody, instead of always using fromPublisher() which loses it.

HTTP request construction (sdk-core)

  • MakeAsyncHttpRequestStage — Don't set Content-Length if Transfer-Encoding is already present. These are mutually exclusive per RFC 7230 §3.3.2. Pre-existing latent bug exposed by InMemoryPublisher now correctly reporting content length.

Testing

Added unit and integration tests

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

License

  • I confirm that this pull request can be released under the Apache 2 license

@davidh44 davidh44 requested a review from a team as a code owner July 10, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant