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

Plugin instances leak between sibling class loaders #30

Open
reda-alaoui opened this issue Jan 6, 2017 · 0 comments
Open

Plugin instances leak between sibling class loaders #30

reda-alaoui opened this issue Jan 6, 2017 · 0 comments

Comments

@reda-alaoui
Copy link
Member

reda-alaoui commented Jan 6, 2017

Suppose we have a JVM running 3 class loaders:

  • Class loader System
  • Class loader of application A having its own jai-image-core.jar in its classpath
  • Class loader of application B having its own jai-image-core.jar in its classpath

This is the kind of classloader tree that is used in a webapp container like tomcat.

ImageIO is loaded by the class loader system since it resides in the jdk.

Suppose also that:

  • At startup, application A launches ImageIO.scanForPlugins()
  • At startup, after app A, application B launches ImageIO.scanForPlugins()

When application B calls ImageIO for any operation, ImageIO will scan its plugin registry and return the first plugin able to fullfill the operation.
But in our specific case, the plugin returned by the registry, to application A, will be the one loaded by Application B class loader !

Therefore, plugin instances are leaking between class loaders on WebApp containers.

Maybe this bug should be handled by the JVM vendors, but knowing their reactivities, I propose to handle this issue in each plugin by checking that the current thread classloader or one of its parent loaded the plugin class about to be used.

Incoming PR

@reda-alaoui reda-alaoui changed the title Plugin instances leaking between class loaders Plugin instances leak between class loaders Jan 6, 2017
@reda-alaoui reda-alaoui changed the title Plugin instances leak between class loaders Plugin instances leak between sibling class loaders Jan 6, 2017
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

1 participant