spring-projects / spring-projects/spring-data-mongodb

Entity checked on wrong type, when enable EnableMongoAuditing [DATAMONGO-2420]

Open
#3,278 2 comments 0 reactions 1 assignee View on GitHub

@christophstrobl is already working on this.

Since Dec 30, 2020.

type: bug
Dominant language
Java
Stars
1.7k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

dzonekl opened DATAMONGO-2420 and commented

In a spring boot application (2.2.1), having auditing enabled. (@EnableMongoAuditing), an exception is thrown on a field of type List<...> or Set<...> 

java.lang.IllegalArgumentException: Target bean of type java.util.ArrayList is not of type of the persistent entity (Comment)!: java.util.ArrayList

at org.springframework.util.Assert.instanceCheckFailed(Assert.java:696)at org.springframework.util.Assert.instanceCheckFailed(Assert.java:696) at org.springframework.util.Assert.isInstanceOf(Assert.java:615) at org.springframework.data.mapping.model.BasicPersistentEntity.verifyBeanType(BasicPersistentEntity.java:551) at org.springframework.data.mapping.model.BasicPersistentEntity.getPropertyAccessor(BasicPersistentEntity.java:453) at org.springframework.data.mapping.PersistentPropertyAccessor.setProperty(PersistentPropertyAccessor.java:76) at org.springframework.data.auditing.MappingAuditableBeanWrapperFactory$MappingMetadataAuditableBeanWrapper.lambda$setDateProperty$2(MappingAuditableBeanWrapperFactory.java:243) at java.lang.Iterable.forEach(Iterable.java:75)

 

Attachments: debug state of the bean, when hitting method verifyBeanType 

Screenshot 1 - Successful without @EnableMongoAuditing

Screenshot 2 - Exception occurs

 

 

 

 


Attachments:

Issue Links:

  • DATACMNS-1609 Auditing metadata should not detect paths containing map or collection like segments

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.