Skip to content

refactor(jdbc): extract parameter stream reads - #279

Merged
magnusp merged 1 commit into
mainfrom
refactor/parameter-streams
Oct 31, 2026
Merged

magnusp merged 1 commit into
mainfrom
refactor/parameter-streams

Conversation

@magnusp

@magnusp magnusp commented Oct 31, 2026

Copy link
Copy Markdown
Owner

What changed

Moved the six private stream readers out of LibsqlPreparedStatement into a package-private ParameterStreams. The setters keep the JDBC surface and the parameter index handling. ParameterStreams owns the conversion of an InputStream or Reader into the bytes, text, or Value that a setter binds.

Behavior preserved

Every setter binds the same Value. Every exception type and message is unchanged, including the length bounds, the short-stream messages, and the read-failure messages. A null stream still binds SQL NULL. The public API is unchanged.

Pins added

Test Behavior pinned
nullStreamsBindSqlNull Null binary, character, and ASCII streams bind SQL NULL.
streamLengthOutsideIntRangeUsesTheXerialMessage Negative and over-int lengths keep Data must have a length between 0 and Integer.MAX_VALUE.
shortBinaryStreamUsesTheXerialMessage A short byte stream keeps End of stream reached before 5 bytes were read.
shortCharacterStreamUsesTheXerialMessage A short reader keeps End of stream reached before 5 characters were read.
binaryReadFailureKeepsTheXerialMessage An IOException keeps Cannot read from binary stream: boom.
characterReadFailureKeepsTheXerialMessage An IOException keeps Cannot read from character stream: boom.
asciiStreamDecodesAsAsciiAndUnicodeStreamDecodesAsUtf8 The ASCII setter replaces non-ASCII bytes; the deprecated Unicode setter decodes UTF-8.

Mutant kills

Probe Result
Decode the ASCII setter as UTF-8. 1 pin failed. Reverted.
Change the short byte-stream message from bytes to chars. 1 pin failed. Reverted.

Diff (file statistics)

 LibsqlPreparedStatement.java      | 125 +++------------------
 ParameterStreams.java            | 115 +++++++++++++++++++
 LibsqlPreparedStatementTest.java  | 108 ++++++++++++++++++
 3 files changed, 239 insertions(+), 109 deletions(-)

Line counts

File Before After
LibsqlPreparedStatement.java 602 509
ParameterStreams.java 0 115

Probe

The first probe changed the ASCII decoder to UTF-8, and the decoding pin failed. The second probe changed the short byte-stream message from bytes to chars, and the message pin failed. Both probes were reverted before the final lane run.

Lanes

Command Result
mise exec -- ./mvnw -pl libsql-jdbc -am test Pass, 1564 tests (baseline 1557 plus 7 pins).
mise exec -- ./mvnw spotless:check Pass.
mise exec -- ./mvnw -pl libsql-conformance -am verify Pass, 271 tests, 6 skipped.
DOCKER_CONFIG=... mise exec -- ./mvnw -pl libsql-itests -am verify Pass, 43 driver ITs and 192 itests.
  • My code follows the code style of this project (./mvnw spotless:check).
  • I have added tests that prove my fix is effective or that my feature works.
  • All new and existing tests passed (./mvnw clean verify).
  • I have updated documentation where appropriate.

Closes #278

@magnusp
magnusp force-pushed the refactor/parameter-streams branch from 469e1ec to 09e147e Compare October 31, 2026 10:39
@magnusp
magnusp merged commit 3b4502b into main Oct 31, 2026
6 checks passed
@magnusp
magnusp deleted the refactor/parameter-streams branch October 31, 2026 10:47
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.

Extract parameter stream reads from LibsqlPreparedStatement

1 participant