Problem
InputStream.read(byte[], off, len) from ByteFlow.runToInputStream continues reading until len bytes are filled or the stream ends. Short reads are not returned once some data is available.
Impact
Consumers that request large buffers, including Jackson’s array parser (~8 KiB), can stall or deadlock with incremental/demand-driven sources even when enough bytes are already available to decode the next value.
Related consequences of the current bridge:
- Concurrent read-ahead through the channel buffer.
- Early cancellation may hang if upstream is blocked in a non-interruptible
InputStream.read.
Expected
Bulk reads should return after copying currently available bytes (legal short reads), matching normal InputStream behavior.
Suggested tests
- Source emits a small chunk and then waits; a bulk read returns the available bytes without waiting for more.
- Offset/length and empty-chunk cases still behave correctly.
Follow-up after fix
In the JSON module, strengthen parseArray latency/cancellation regressions to assert prompt element emission.
Notes
Discovered while adding the JSON module. Array parsing currently uses this API and inherits the limitation.
Problem
InputStream.read(byte[], off, len)fromByteFlow.runToInputStreamcontinues reading untillenbytes are filled or the stream ends. Short reads are not returned once some data is available.Impact
Consumers that request large buffers, including Jackson’s array parser (~8 KiB), can stall or deadlock with incremental/demand-driven sources even when enough bytes are already available to decode the next value.
Related consequences of the current bridge:
InputStream.read.Expected
Bulk reads should return after copying currently available bytes (legal short reads), matching normal
InputStreambehavior.Suggested tests
Follow-up after fix
In the JSON module, strengthen
parseArraylatency/cancellation regressions to assert prompt element emission.Notes
Discovered while adding the JSON module. Array parsing currently uses this API and inherits the limitation.