Skip to content

Never return null when mapping to protobuf format objects #498

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

erlendnils1
Copy link
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
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