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

FasterXML Jackson typeCache ClassLoader leak #75

Closed
cymurg opened this issue Jan 5, 2018 · 5 comments
Closed

FasterXML Jackson typeCache ClassLoader leak #75

cymurg opened this issue Jan 5, 2018 · 5 comments

Comments

@cymurg
Copy link

cymurg commented Jan 5, 2018

Hi ,

FasterXML which bundled with WebLogic has a classloader leak that causes to hold application classloader.

com.fasterxml.jackson.databind.type.TypeFactory#_typeCache holds some cache data that can refer application classes and application classloader at the same time.

Here is a screenshot that shows the leak;
capture
Note: AgencyRequestHeader class is loaded by our application class loader.

This problem had been reported on github but i think it is still exists at newest version. At least I know that it exists at weblogic 12.
FasterXML/jackson-databind#1363

Invoking TypeFactory.defaultInstance().clearCache() at cleanup stage in leak-prevention api can solve the problem.

@mjiderhamn
Copy link
Owner

Thanks for the report!

Would you care to try out my suggested fix by compiling from sources, before I prepare another release?

@cymurg
Copy link
Author

cymurg commented Jan 8, 2018

Hi,

Surprisingly it said "NoSuchMethod" for "clearCache()"

When I investigated that error i saw that _typeCache is instance of LRUMap (as we can see above screenshot) but at 2.9.4 version _typeCache is instance of SimpleLookupCache

After more investigation i realized that "clearCache()" is not exists before 2.4 version and LRUMap extends LinkedHashMap and has no clear method at these versions. At 2.8 version, LRUMap is still exists but it wraps ConcurrentHashMap as _map variable and has clear method.

At our test environment, using wls-cat I found that LRUMap is loaded by 2.8.4 version so your fix probably works but at my local environment old version is loaded for some reason i do not understand. To solve this problem i modified your fix like that if clearCache() method is exists invoke it but if doesn't exist than find _typeCache object and invoke _typeCache.getClass().getSuperClass().clear() and it has worked.
Note : _typeCache.getClass().getSuperClass() is LinkedHashMap before version 2.4

Thanks for your fix.

@cymurg cymurg changed the title FasterXML Cache ClassLoader leak FasterXML Jackson typeCache ClassLoader leak Jan 8, 2018
@mjiderhamn
Copy link
Owner

Seems that clearCache() was introduced in Jackson 2.4.1. I've made some changes to make the prevention compatible with older Jackson versions, though the test case did't cause a leak with 2.4.0 so I haven't verified it works as expected. Would you care to give it a spin in your test environment?

@cymurg
Copy link
Author

cymurg commented Jan 9, 2018

I have tested and it is ok now

@mjiderhamn
Copy link
Owner

This was included in version 2.6.0 just released to Maven Central.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants