You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Rui Wang (Jira)" <ji...@apache.org> on 2026/10/14 04:56:00 UTC
[jira] [Updated] (HDDS-16789) Make Buffers.pollAll() allows empty buffer instead of failing on empty deque
[ https://issues.apache.org/jira/browse/HDDS-16789?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Rui Wang updated HDDS-16789:
----------------------------
Summary: Make Buffers.pollAll() allows empty buffer instead of failing on empty deque (was: Make Buffers.pollAll() return empty buffer instead of failing on empty deque)
> Make Buffers.pollAll() allows empty buffer instead of failing on empty deque
> ----------------------------------------------------------------------------
>
> Key: HDDS-16789
> URL: https://issues.apache.org/jira/browse/HDDS-16789
> Project: Apache Ozone
> Issue Type: Sub-task
> Reporter: Rui Wang
> Assignee: Rui Wang
> Priority: Major
> Labels: pull-request-available
>
> h2. Problem
> `Buffers.pollAll()` in the KeyValue stream write path throws `IllegalStateException` when the internal deque is empty (`Preconditions.checkState(!deque.isEmpty(), ...)`).
> Callers such as `KeyValueStreamDataChannel.drainBuffers()` must guard with `buffers.isEmpty()` before calling `pollAll()`, which duplicates checks and makes the API easy to misuse.
> h2. Proposed change
> * When the deque is empty, `pollAll()` returns `ReferenceCountedObject.wrap(Unpooled.EMPTY_BUFFER)` instead of throwing.
> * Simplify `KeyValueStreamDataChannel.drainBuffers()` by removing the explicit `isEmpty()` early return; repeated drains remain a no-op.
> * In the close path that flushes buffered data without parsing a stream PutBlock (`writeBuffers()`), skip `setEndIndex` / file writes when the polled buffer is not readable (e.g. close with no prior writes).
> Behavior for `closeBuffers()` / stream PutBlock close is unchanged: an empty buffer still fails when reading the PutBlock trailer, which is expected for a malformed close.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org