-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
MimeTypes resource loading incorrect on OSGi #797
Comments
Pass MimeTypes.class as the classloader source. No unit test to confirm the fix.
@janbartel I've switched the loader class to MimeTypes, but we probably should have a unit test for this, can you look at that? |
@janbartel Note also that in 9.4.x we no longer have a class argument to the loader, so a different solution will be required. |
@gregw the solution to both 9.3 and 9.4 behaviour is to simply re-instate the use of the ResourceBundle instead of Loader.getResource(): ResourceBundle uses the classloader of the MimeTypes class, which is what is desired. |
@mbechler FYI issue #705 is also relevant for jetty-9.4. Although in this case the problem will be solved if we revert to using ResourceBundle to load the mime types, in general if using in an osgi environment, you'll need to have a reasonable thread context classloader set up before accessing jetty classes. |
Wouldn't using MimeTypes.class.getClassLoader().getResource(..) solve all the issues at hand (for MimeTypes, extension loading is of course a different beast)? Doesn't do ResourceBundle's magic, does not use Loader and uses the correct classloader. |
@mbechler actually ClassLoader.getResource() implements the java classloader search order, which is parent first. So it will actually try the parent first (or bootstrap classloader if there is no parent) before failing back to the actual classloader. So that doesn't seem totally ideal either. However,I've changed it to use your suggestion in jetty-9.3 and beyond. I'll close this issue for now, but let us know if there are any problems. |
Starting with 9.3.11 (#723) fails to load the bundled mime type resources in OSGI and logs two warnings.
The new code seems to load the resources through HashMap's (== bootstrap, with Loader falling back to system) classloader with is quite obviously wrong and should be MimeTypes.class or something like that.
The text was updated successfully, but these errors were encountered: