Repository navigation
[azure-core] Fix partial InputStream response buffering - #50837
Merged
Alan Zimmer (alzimmermsft) merged 4 commits intoOct 26, 2026
Merged
Alan Zimmer (alzimmermsft) merged 4 commits into
Alan Zimmer (alzimmermsft) merged 4 commits into
Conversation
Emit partial response data once no additional bytes are immediately available, while opportunistically coalescing buffered bytes up to the configured chunk size. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7eaead83-8f9e-4c68-9958-ad8e66668356
Verify JDK and OkHttp clients deliver a flushed SSE frame before the response reaches EOF. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7eaead83-8f9e-4c68-9958-ad8e66668356
|
Azure Pipelines: Successfully started running 1 pipeline(s). 34 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Xiaofei Cao (XiaofeiCao)
marked this pull request as ready for review
October 16, 2026 09:34
Xiaofei Cao (XiaofeiCao)
requested review from
a team,
Jonathan Giles (JonathanGiles),
Alan Zimmer (alzimmermsft) and
vcolin7
as code owners
October 16, 2026 09:34
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The localized buffering correction has targeted unit and HTTP regression coverage, with no identified blocking defects.
0 open findings
What changed in this PR
Fixes Azure Core’s InputStream response buffering so flushed partial data can reach streaming consumers without waiting for a full chunk or EOF.
Changes:
- Limits additional reads to immediately available bytes.
- Adds unit and shared HTTP regression coverage for partial responses.
- Documents the streaming fix in the changelog.
| File | Description |
|---|---|
| sdk/core/azure-core/src/test/java/com/azure/core/validation/http/HttpClientTestsServer.java | Adds a flushed response with delayed completion. |
| sdk/core/azure-core/src/test/java/com/azure/core/validation/http/HttpClientTests.java | Verifies early delivery through sync and async clients. |
| sdk/core/azure-core/src/test/java/com/azure/core/util/FluxUtilTest.java | Tests partial reads before stream completion. |
| sdk/core/azure-core/src/main/java/com/azure/core/util/FluxUtil.java | Emits partial buffers without waiting to fill them. |
| sdk/core/azure-core/CHANGELOG.md | Records the streaming behavior fix. |
🧠 Review effort: Balanced
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 7eaead83-8f9e-4c68-9958-ad8e66668356
Alan Zimmer (alzimmermsft)
approved these changes
Oct 19, 2026
Alan Zimmer (alzimmermsft)
approved these changes
Oct 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Bug
FluxUtil.toFluxByteBuffercontinues reading until its configured chunk is full or EOF is reached. A small flushed response chunk is therefore withheld while the next read blocks, which can stall long-lived streams such as SSE.The bug affects JDK sync and OkHttp sync/async response streaming. JDK async, Netty, and Vert.x do not have this issue.
Azure Search #50648 consumes streaming
BinaryDatathroughbody.toFluxByteBuffer()for async APIs andbody.toStream()for sync APIs.JDK sync converts its response
InputStreamthroughFluxUtil.toFluxByteBuffer, while OkHttp sync/async useFluxUtil.toFluxByteBuffer(responseBody.byteStream(), 8192). JDK async uses the JDK publisher directly, Netty uses Reactor NettyByteBufFlux, and Vert.x usesBuffercallbacks.Fix
Perform one demand-driven blocking read, coalesce only bytes reported as immediately available, and emit the partial buffer without waiting for the configured chunk to fill.
This fixes JDK sync and OkHttp sync/async while preserving the existing behavior of JDK async, Netty, and Vert.x.
Validation
Added unit and shared HTTP-client coverage verifying flushed partial responses arrive before EOF. Azure Core tests passed (11,891 tests, 3 skipped), including targeted JDK and OkHttp sync/async regressions. Checkstyle and SpotBugs also passed.
All SDK Contribution checklist:
General Guidelines and Best Practices
Testing Guidelines