Skip to content

Never return null when mapping to protobuf format objects#498

Merged
erlendnils1 merged 3 commits into
mainfrom
map_to_proto_never_null
Aug 6, 2025
Merged

Never return null when mapping to protobuf format objects#498
erlendnils1 merged 3 commits into
mainfrom
map_to_proto_never_null

Conversation

@erlendnils1

Copy link
Copy Markdown
Contributor

Null return values when mapping to protobuf format will cause nullPointerExceptions in builders.

This includes the parts of the suggested change from #177 that concerns mapping TO protbuf types, but not the parts concerning mapping FROM protobuf types. For the latter the current impl of returning null for empty/defaultInstance values has some merit as it is the only way for clients to detect and handle not populated fields. The suggestion of supporting multiple implementations for mapping FROM protobuf format (from #177) still looks like viable option for allowing clients to choose between null/empty values

This should also support half of #451 in a similar way

erlend added 3 commits June 24, 2025 09:55
# Conflicts:
#	support-core/src/main/java/no/entur/abt/mapstruct/common/ProtobufStandardMappings.java
@erlendnils1 erlendnils1 merged commit cf2d524 into main Aug 6, 2025
1 check passed
@erlendnils1 erlendnils1 deleted the map_to_proto_never_null branch August 6, 2025 06:40
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