Skip to content
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

Fix NPE caused by fields with WRITE_ONLY access #222

Merged
merged 1 commit into from Feb 8, 2022

Conversation

volomas
Copy link
Contributor

@volomas volomas commented Jan 28, 2022

NullPointerException is thrown during insert when any field marked with
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY):

java.lang.NullPointerException at org.mongojack.internal.AnnotationHelper.hasIdAnnotation(AnnotationHelper.java:36) at org.mongojack.internal.stream.JacksonCodec.lambda$getIdElementSerializationDescription$11(JacksonCodec.java:221) at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:176)

This happens because POJOPropertyBuilder::getPrimaryMember in case of serialization returns null when field is meant for deseriazliation only (according to WRITE_ONLY annotation)

Here is reproducer: https://github.com/Skipua/mongojack-jackson-writeonly-issue

@rlodge rlodge merged commit cac8906 into mongojack:master Feb 8, 2022
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.

None yet

2 participants