spring-projects / spring-projects/spring-data-rest
NPE in PersistentPropertyResourceMapping.isExported using SD MongoDB @DbRef Object [DATAREST-796]
Open
@odrotbohm is already working on this.
Since Dec 31, 2020.
in: repository
type: bug
- Dominant language
- Java
- Stars
- 958
- Forks
- 568
- PR merge metrics
- No merged PRs in 30d
Description
Mark Paluch opened DATAREST-796 and commented
Spring Data Rest with Spring Data MongoDB runs into a NPE when using DbRef on Object properties in the associated class.
Model:
@Data
@NoArgsConstructor
@Document(collection = "model")
public static class Model {
@Id
private ObjectId id;
private String name;
@DBRef
private Set<Post> posts;
}
@Data
@NoArgsConstructor
@Document(collection = "post")
public static class Post {
@Id
private ObjectId id;
@DBRef
private Object owner;
}
Stack-trace:
java.lang.NullPointerException: null
at org.springframework.data.rest.core.mapping.PersistentPropertyResourceMapping.isExported(PersistentPropertyResourceMapping.java:84) ~[spring-data-rest-core-2.4.4.RELEASE.jar:na]
at org.springframework.data.rest.core.mapping.MappingResourceMetadata.isExported(MappingResourceMetadata.java:77) ~[spring-data-rest-core-2.4.4.RELEASE.jar:na]
at org.springframework.data.rest.webmvc.mapping.AssociationLinks.isLinkableAssociation(AssociationLinks.java:95) ~[spring-data-rest-webmvc-2.4.4.RELEASE.jar:na]
at org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$AssociationUriResolvingDeserializerModifier.updateBuilder(PersistentEntityJackson2Module.java:339) ~[spring-data-rest-webmvc-2.4.4.RELEASE.jar:na]
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:240) ~[jackson-databind-2.6.5.jar:2.6.5]
Affects: 2.4.4 (Gosling SR4), 2.5 RC1 (Hopper)
Reference URL: https://gist.github.com/mp911de/1edbc0ad7b3ae621cc491ac6f2f2e100
Issue Links:
- DATAREST-797 NPE in LinkCollectingAssociationHandler.doWithAssociation using SD MongoDB
@DbRefObject
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.