ClassLoaderServiceImpl should be defined as Stoppable

Description

There are reports of Hibernate holding on to references of class loaders in a way that is somehow causing that ClassLoader to leak in Wildfly/Jipijapa. The details are a little fuzzy still, but in looking through some of the ServiceRegistry code and specifically the ClassLoaderServiceImpl and its internal AggregatedClassLoader (because of heapdump from ) it seems like this could be caused because ClassLoaderServiceImpl's AggregatedClassLoader does not release the ClassLoader references it holds.

The heapdump pointed to a class we load from Jipijapa through a JDK ServiceLoader lookup using the AggregatedClassLoader. JDK ServiceLoader does do some caching of the service impls it loads somehow linked to the classloader. java.util.ServiceLoader does provide a way to refresh this cache. But not a way, that I can see, to clear it. Just something else to consider here..

The idea here is to make ClassLoaderServiceImpl implement Stoppable so that it can receive callback from the ServiceRegistry shutdown process so that it can release these resources.

Environment

None

Activity

Show:
Brett Meyer
September 5, 2013, 10:32 PM
Edited

& :

Unless I'm missing something, I think the PR is incomplete. Only the ServiceBindings within StandardServiceRegistryImpl (AbstractServiceRegistryImpl) will be stopped. But ClassLoaderServiceImpl is in the parent registry (BootstrapServiceRegistryImpl). Having AbstractServiceRegistryImpl#destroy() call parent#destroy(), then wiring in cleanup there, should do it.

There's another gap where AbstractServiceRegistryImpl#createServiceBinding wasn't adding the binding to #serviceBindingList, used in destroy.

Am I missing anything?

Tomaž Cerar
September 5, 2013, 10:42 PM

You are right, i am just chasing this down

Brett Meyer
September 5, 2013, 10:45 PM

, let me throw what I have into a new PR and have you look at it.

Tomaž Cerar
September 5, 2013, 10:47 PM

or just tell me name of your branch

Assignee

Brett Meyer

Reporter

Steve Ebersole

Fix versions

Labels

None

backPortable

None

Suitable for new contributors

None

Requires Release Note

None

Pull Request

None

backportDecision

None

Affects versions

Priority

Major
Configure