Skip to content

fix(util): round-trip null Value in ValueOrCompletion serialization#47

Merged
rossdanderson merged 1 commit into
mainfrom
fix/value-or-completion-null-value
Jun 19, 2026
Merged

fix(util): round-trip null Value in ValueOrCompletion serialization#47
rossdanderson merged 1 commit into
mainfrom
fix/value-or-completion-null-value

Conversation

@rossdanderson

Copy link
Copy Markdown
Collaborator

Summary

A materialized Flow<T?> that emits null produces ValueOrCompletion.Value(null), but none of the three serializers could round-trip it. Adding the missing null-value tests surfaced the bug across all backends.

Serializer Failure before fix
Fory NullPointerExceptionreadRef() as Any force-casts a null ref to non-null Any
Jackson 2 JsonMappingException "Missing value field"
Jackson 3 DatabindException "Missing value field"

The Jackson deserializers conflated field absent with field present but null (node.get("value")?.let{…} ?: throw), so a serialized "value": null was rejected on read.

Changes

  • Fory ValueOrCompletionSerializer — drop the as Any non-null cast on read.
  • Jackson 2 / 3 ValueOrCompletionDeserializer — throw only when the value field is genuinely absent; treat a present null node as a real null.
  • Added a Value (null) round-trip test to each of the fory / jackson2 / jackson3 serialization specs.

Notes

  • Touches only internal serializer classes; ValueOrCompletion's public surface is unchanged. apiCheck passes with no .api diff — patch-level bug fix.
  • ./gradlew :datasourcex-util:check passes (tests, apiCheck, spotlessCheck, koverVerify).

A materialized Flow<T?> that emits null produces Value(null), but none
of the serializers could round-trip it:

- Fory force-cast the read ref to non-null Any (NullPointerException).
- The Jackson 2/3 deserializers conflated an absent value field with a
  present-but-null one, throwing "Missing value field" on "value": null.

Drop the Fory non-null cast, and in both Jackson deserializers throw only
when the field is genuinely absent, treating a present null node as null.

Adds a null-Value round-trip test to each serialization spec.
@rossdanderson rossdanderson merged commit 05355d2 into main Jun 19, 2026
3 checks passed
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.

1 participant