Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException in RepositoryFactoryBeanSupport.getObject(…) [DATACMNS-1642] #2068

Closed
spring-projects-issues opened this issue Dec 28, 2019 · 2 comments
Assignees
Labels
in: repository Repositories abstraction type: bug A general bug

Comments

@spring-projects-issues
Copy link

Mark Paluch opened DATACMNS-1642 and commented

Trying to bootstrap a repository can lead to a NullPointerException in RepositoryFactoryBeanSupport.getObject(…).

 

What happens:

  • RepositoryFactoryBean gets initialized in afterPropertiesSet()
  • Initialization requests the type from the MappingContext
  • MappingContext publishes an application event
  • ApplicationEventMulticaster looks up event listeners from the context
  • Bean lookup calls getObject(…) method on the RepositoryFactoryBean that is currently initialized. The repository field was not yet set therefore the call fails with an NPE

 

Stack trace and reproducer are attached


Affects: 2.2.3 (Moore SR3)

Attachments:

@spring-projects-issues
Copy link
Author

Mark Paluch commented

It turns out that the repository factory bean that is under initialization produces a type that is required by an ApplicationEventListener

@spring-projects-issues
Copy link
Author

Spencer Gibb commented

Fix from the Spring Cloud side spring-cloud/spring-cloud-gateway#1510

@spring-projects-issues spring-projects-issues added type: bug A general bug in: repository Repositories abstraction labels Dec 30, 2020
@mp911de mp911de assigned mp911de and unassigned odrotbohm Jan 26, 2021
@mp911de mp911de added this to the 2.3.7 (Neumann SR7) milestone Jan 26, 2021
mp911de added a commit that referenced this issue Jan 26, 2021
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
mp911de added a commit that referenced this issue Jan 26, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: repository Repositories abstraction type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants