Skip to content

CachedIntrospectionResults cannot be cleared for null class loaders [SPR-9189] #13827

@spring-projects-issues

Description

@spring-projects-issues

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

Metadata

Metadata

Assignees

Labels

status: backportedAn issue that has been backported to maintenance branchestype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions