Guard potential null dereference in recursive initialization calls.
We now assign the repository field before resolving the persistent entity through the mapping context to avoid a potential NPE caused by a getObject(…) invocation through an application event. Closes #2068
This commit is contained in:
@@ -320,11 +320,11 @@ public abstract class RepositoryFactoryBeanSupport<T extends Repository<S, ID>,
|
||||
|
||||
this.repositoryMetadata = this.factory.getRepositoryMetadata(repositoryInterface);
|
||||
|
||||
this.repository = Lazy.of(() -> this.factory.getRepository(repositoryInterface, repositoryFragmentsToUse));
|
||||
|
||||
// Make sure the aggregate root type is present in the MappingContext (e.g. for auditing)
|
||||
this.mappingContext.ifPresent(it -> it.getPersistentEntity(repositoryMetadata.getDomainType()));
|
||||
|
||||
this.repository = Lazy.of(() -> this.factory.getRepository(repositoryInterface, repositoryFragmentsToUse));
|
||||
|
||||
if (!lazyInit) {
|
||||
this.repository.get();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user