Rui Wang created HDDS-16789:
-------------------------------
Summary: Make Buffers.pollAll() return 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: Improvement
Reporter: Rui Wang
Assignee: Rui Wang
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: [email protected]
For additional commands, e-mail: [email protected]