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

JarHell: Check the parent classloader rather than the system classloader #16726

Closed
pickypg opened this issue Feb 18, 2016 · 6 comments
Closed
Labels
:Core/Infra/Core Core issues without another label feedback_needed

Comments

@pickypg
Copy link
Member

pickypg commented Feb 18, 2016

Currently, JarHell checks the system classloader to find issues with jar collisions.

In order to support OSGi environments for testing embedded nodes, it's effectively a requirement that the parent classloader be checked instead.

Pros:

  • The ability to embed ES into an OSGi environment, generally for testing capabilities in integration tests.

Cons:

  • We currently do not support OSGi environments, which is why we do not test against them. Doing this type of check explicitly
  • Embedding nodes is not a recommended or supported in any environment.
  • This introduces the potential for unexpected issues "just" for the sake of supporting OSGi.
  • Supporting Java 9's jigsaw modularity may require different semantics.
@rmuir
Copy link
Contributor

rmuir commented Feb 18, 2016

There isn't a way to check an arbitrary classloader. If its a URLClassLoader, then you can, but this is not the case anymore since jigsaw. That's why java.class.path is used: it works everywhere when elasticsearch is run the way we run it (which is not OSGI).

Adding a special hook for running in an OSGI container, e.g. an instanceof URLClassLoader might seem like a good idea, but then we lose important checks for everyone on java 8 that happen in the parsing itself (these detect e.g. stale shell scripts that add empty classpath elements, which convert to surprising locations).

trying to be even smarter and conditionally do something "only when its a URLClassLoader and we are in a container" is fairly sneaky, but might work. But we have to add this "container detection" logic (which likely needs special privileges for CL.getSystemClassLoader call) during bootstrap and expose it in BootStrapInfo... and somehow know that all this is working properly when we don't test running inside any containers. And there is really no guarantee containers are using URLClassLoaders.

@s1monw
Copy link
Contributor

s1monw commented Feb 18, 2016

there is also a setting in 2.2 that allows you to disable jarhell checks for testing tests.jarhell.check=false this might be the better solution for testing?

@pickypg
Copy link
Member Author

pickypg commented Feb 19, 2016

@s1monw It ends up being bypassed when testing with plugins because the plugin manager bypasses the check.

@rjernst
Copy link
Member

rjernst commented Feb 19, 2016

@pickypg Not if you construct a Node the new way. In master that would be using the Node constructor directly which takes plugin classes, or on 2.x using MockNode (as our tests do).

@s1monw
Copy link
Contributor

s1monw commented Feb 21, 2016

@pickypg is this solving you issue, can we close?

@jasontedor
Copy link
Member

jasontedor commented Aug 30, 2016

We do not support embedded Elasticsearch nodes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Core Core issues without another label feedback_needed
Projects
None yet
Development

No branches or pull requests

6 participants