Skip to content

Fix NPE caused by fields with WRITE_ONLY access#222

Merged
rlodge merged 1 commit into
mongojack:masterfrom
volomas:bugfix/fix-npe-on-writeonly-field
Feb 8, 2022
Merged

Fix NPE caused by fields with WRITE_ONLY access#222
rlodge merged 1 commit into
mongojack:masterfrom
volomas:bugfix/fix-npe-on-writeonly-field

Conversation

@volomas
Copy link
Copy Markdown
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.

2 participants