eclipse-ee4j / eclipse-ee4j/jersey
AbstractJaxbProvider WeakReference JAXBContexts causing ClassLoader Leak
- Dominant language
- Java
- Stars
- 730
- Forks
- 382
- PR merge metrics
- No merged PRs in 30d
Description
Leak Observed in Jersey version `2.25` and `2.27`.
Classes being loaded multiple times due to [this hashmap](https://github.com/eclipse-ee4j/jersey/blob/master/media/jaxb/src/main/java/org/glassfish/jersey/jaxb/internal/AbstractJaxbProvider.java#L59) having a weak reference values. As a result, [This method](https://github.com/eclipse-ee4j/jersey/blob/master/media/jaxb/src/main/java/org/glassfish/jersey/jaxb/internal/AbstractJaxbProvider.java#L286) will create a new JAXBContext for a class that has _already_ been loaded when the weakly referenced values are collected by the garbage collector; forcing a new class to be loaded by the ClassLoader.
Our application observed a class count for `JaxbAccessorM_*` in the thousands which eventually lead to an OOME.
I would advise swapping the `WeakReference` with a `SoftReference` to prevent the eager collection of these JAXBContexts.
Contributor guide
Research direction
Start in media/jaxb/src/main/java/org/glassfish/jersey/jaxb/internal/AbstractJaxbProvider.java, especially the hashmap near line 59 and the method near line 286. Confirm how collected JAXBContext references cause repeated context creation and class loading; done means preventing the reported ClassLoader leak and resulting class-count growth.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100