-
Notifications
You must be signed in to change notification settings - Fork 1.5k
DATAJPA-1446 - Clear JpaMetamodel CACHE when application context is c… #301
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
Conversation
@@ -109,6 +112,11 @@ public boolean hasPersistentEntityFor(Class<?> type) { | |||
return super.hasPersistentEntityFor(type) || models.isMetamodelManagedType(type); | |||
} | |||
|
|||
@EventListener |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spring library components are not supposed to use @EventListener
(it's a choice for application developers, but it's really inefficient, so not a good idea for libraries). You could put this in a @PreDestroy
though, I expect (or DisposableBean
probably better).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the review! I just updated my PR to use a DisposableBean
instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, implementing DisposableBean
in class JpaMetamodelMappingContext
was not triggering anything when application context is closed. Since JpaMetamodelMappingContextFactoryBean
already implements DisposableBean
, I decided to update my PR to clean the cache here instead.
This time, the cache is cleaned when applicationContext is closed.
0eeb77f
to
d360807
Compare
d360807
to
1d4c96e
Compare
…losed. We now register a dedicated Spring Bean to wipe the static cache in JpaMetamodel to avoid memory from leaking in scenarios where ApplicationContexts are started and closed very often (e.g. integration tests). Heavily inspired by the work Sylvere Richard (@Nowheresly) has done in #301 but the key responsibility of wiping moved away from the MappingCOntext implementation. Original pull request #301.
…losed. We now register a dedicated Spring Bean to wipe the static cache in JpaMetamodel to avoid memory from leaking in scenarios where ApplicationContexts are started and closed very often (e.g. integration tests). Heavily inspired by the work Sylvere Richard (@Nowheresly) has done in #301 but the key responsibility of wiping moved away from the MappingCOntext implementation. Original pull request #301.
…losed. We now register a dedicated Spring Bean to wipe the static cache in JpaMetamodel to avoid memory from leaking in scenarios where ApplicationContexts are started and closed very often (e.g. integration tests). Heavily inspired by the work Sylvere Richard (@Nowheresly) has done in #301 but the key responsibility of wiping moved away from the MappingCOntext implementation. Original pull request #301.
That's complete. I took a slightly different approach, see the ticket comment for details. Kept the credits in the classes around and attributed you in the commit message. |
…losed. We now register a dedicated Spring Bean to wipe the static cache in JpaMetamodel to avoid memory from leaking in scenarios where ApplicationContexts are started and closed very often (e.g. integration tests). Heavily inspired by the work Sylvere Richard (@Nowheresly) has done in spring-projects#301 but the key responsibility of wiping moved away from the MappingCOntext implementation. Original pull request spring-projects#301.
…losed.