Skip to content

Add streaming I/O methods to JsonCodec SPI - #6246

Merged
tsegismont merged 4 commits into
eclipse-vertx:masterfrom
tsegismont:json-improvements
Jul 31, 2026
Merged

Add streaming I/O methods to JsonCodec SPI#6246
tsegismont merged 4 commits into
eclipse-vertx:masterfrom
tsegismont:json-improvements

Conversation

@tsegismont

@tsegismont tsegismont commented Jul 15, 2026

Copy link
Copy Markdown
Member

Allow JSON decoding/encoding directly from/to streams and character sources, so that SQL clients can avoid intermediate String or byte[] allocations.

  • fromInputStream / toOutputStream for UTF-8 wire encodings (PG, MySQL)
  • fromReader / toWriter for non-UTF-8 wire encodings (e.g. MSSQL with UTF-16LE)

Some portions of this content were created with the assistance of Claude Opus 4.6

@tsegismont
tsegismont requested a review from vietj July 15, 2026 15:40
@tsegismont

Copy link
Copy Markdown
Member Author

@vietj can you please take a look? It's still a draft because I haven't started the SQL Client updates yet.

@tsegismont tsegismont changed the title Add InputStream/OutputStream methods to JsonCodec SPI Add streaming I/O methods to JsonCodec SPI Jul 16, 2026
@tsegismont tsegismont added this to the 5.2.0 milestone Jul 16, 2026
@tsegismont
tsegismont marked this pull request as ready for review July 16, 2026 15:50
@tsegismont

tsegismont commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

This is ready for review. You can see how the new methods are used in tsegismont/vertx-sql-client@8d716e3

Allow JSON decoding from an InputStream and encoding to an OutputStream, so that SQL clients can pass ByteBufInputStream/ByteBufOutputStream directly and avoid intermediate String allocations.

Assisted-by: Claude Opus 4.6
Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Allow JSON decoding from a Reader and encoding to a Writer, so that SQL clients using non-UTF-8 wire encodings (e.g. MSSQL with UTF-16LE) can avoid intermediate String allocations.

Assisted-by: Claude Opus 4.6
Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Extract shared test implementations behind a boolean parameter (useReader/useWriter) so InputStream/OutputStream and Reader/Writer tests share the same assertion logic.

Assisted-by: Claude Opus 4.6
Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
Comment thread vertx-core/src/main/java/io/vertx/core/spi/json/JsonCodec.java Outdated
Comment thread vertx-core/src/main/java/io/vertx/core/spi/json/JsonCodec.java Outdated
Comment thread vertx-core/src/main/java/io/vertx/core/spi/json/JsonCodec.java Outdated

@vietj vietj left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor naming consistency feedback

Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
@tsegismont
tsegismont merged commit e63488c into eclipse-vertx:master Jul 31, 2026
13 of 15 checks passed
@tsegismont
tsegismont deleted the json-improvements branch July 31, 2026 15:04
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.

2 participants