CachedIntrospectionResults cannot be cleared for null class loaders [SPR-9189] #13827
Labels
status: backported
An issue that has been backported to maintenance branches
type: bug
A general bug
Milestone
Paul Austin opened SPR-9189 and commented
If a class loaded by the system class loader (null) then it is cached by the CachedIntrospectionResults class. However there is no way to clear this item from the cache as clearClassLoader ignores null class loader arguments.
This means that the classCache will include a reference to the CachedIntrospectionResults thus preventing in some cases CachedIntrospectionResults from being garbage collected.
The class that causes this problem in my spring + spring security app is ArrayList. It seems to happen when I include a task scheduler in my application.
I tried to create a simple test case below. But it was able to unload the classes in this case.
public class TestListener implements ServletContextListener {
public void contextInitialized(ServletContextEvent sce) {
CachedIntrospectionResults.acceptClassLoader(Thread.currentThread()
.getContextClassLoader());
BeanUtils.getPropertyDescriptors(ArrayList.class);
}
public void contextDestroyed(ServletContextEvent sce) {
CachedIntrospectionResults.clearClassLoader(Thread.currentThread()
.getContextClassLoader());
}
}
Affects: 3.0.7
Backported to: 3.1.4
The text was updated successfully, but these errors were encountered: