Skip to content

Add DataStream.writeTo() and DataStream fixes#1073

Merged
mtdowling merged 1 commit intomainfrom
datastream-writeto
Mar 13, 2026
Merged

Add DataStream.writeTo() and DataStream fixes#1073
mtdowling merged 1 commit intomainfrom
datastream-writeto

Conversation

@mtdowling
Copy link
Member

Add writeTo(OutputStream) to DataStream interface with optimized overrides in all implementations.

Also:

  • Fix ByteBufferDataStream.asInputStream() to use buffer.duplicate() so the stream remains replayable
  • Add ByteBufferOutputStream utility class
  • Add ByteBufferUtils.wrap(ByteBuffer) helper

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Add writeTo(OutputStream) to DataStream interface with optimized
overrides in all implementations:
- ByteBufferDataStream: writes directly from backing array
- InputStreamDataStream: delegates to transferTo
- PublisherDataStream: subscribes and writes buffers directly
- EmptyDataStream: no-op
- WrappedDataStream: delegates to inner stream

Also:
- Fix ByteBufferDataStream.asInputStream() to use buffer.duplicate()
  so the stream remains replayable
- Add ByteBufferOutputStream utility class
- Add ByteBufferUtils.wrap(ByteBuffer) helper
@mtdowling mtdowling changed the title Add DataStream.writeTo() and IO utilities Add DataStream.writeTo() and DataStream fixes Mar 13, 2026
@mtdowling mtdowling enabled auto-merge (rebase) March 13, 2026 19:47
@mtdowling mtdowling merged commit 1de1d73 into main Mar 13, 2026
4 checks passed
@mtdowling mtdowling deleted the datastream-writeto branch March 13, 2026 19:56
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.

3 participants