Skip to content

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

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

Closed
spring-projects-issues opened this issue Mar 1, 2012 · 3 comments
Assignees
Labels
status: backported An issue that has been backported to maintenance branches type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

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

@spring-projects-issues
Copy link
Collaborator Author

Paul Austin commented

Any updates on this issue?

@spring-projects-issues
Copy link
Collaborator Author

Chris Beams commented

Hi Paul,

Please do what you can to put together a simple project that reproduces this issue. We would have to do the same in order to address it. You can follow the instructions here, thanks!

@spring-projects-issues
Copy link
Collaborator Author

Juergen Hoeller commented

As of 3.2.1 and 3.1.4, clearClassLoader(null) will remove cached classes that have been loaded by the system class loader, as expected.

Juergen

@spring-projects-issues spring-projects-issues added type: bug A general bug status: backported An issue that has been backported to maintenance branches labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 3.2.1 milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: backported An issue that has been backported to maintenance branches type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants