spring-projects / spring-projects/spring-data-rest
NPE in LinkCollectingAssociationHandler.doWithAssociation using SD MongoDB @DbRef Object [DATAREST-797]
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-797 and commented
Spring Data Rest with Spring Data MongoDB runs into a NPE when using DbRef on Object typed properties in the domain class.
Model:
@Data
@NoArgsConstructor
@Document(collection = "model")
public static class Model {
@Id
private ObjectId id;
private String name;
@DBRef
private Object posts;
}
Stack-trace:
Caused by: java.lang.NullPointerException
at org.springframework.data.rest.webmvc.mapping.LinkCollectingAssociationHandler.doWithAssociation(LinkCollectingAssociationHandler.java:101)
at org.springframework.data.mapping.model.BasicPersistentEntity.doWithAssociations(BasicPersistentEntity.java:353)
at org.springframework.data.rest.webmvc.json.PersistentEntityJackson2Module$LinkCollector.getLinksFor(PersistentEntityJackson2Module.java:643)
Affects: 2.4.4 (Gosling SR4), 2.5 RC1 (Hopper)
Reference URL: https://gist.github.com/mp911de/cd330c8a9c6bc056aa61c44fcb8714ac
Issue Links:
- DATAREST-796 NPE in PersistentPropertyResourceMapping.isExported 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.