-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
ServiceLoader round-trips URL to URI and loses associated URLStreamHandler #16846
Labels
good first issue
Good for newcomers
Source: Community
PR or issue was opened by a community user
Team: Core
Type: Defect
Milestone
Comments
mmedenjak
added
Team: Core
Source: Community
PR or issue was opened by a community user
labels
Apr 6, 2020
Unfortunately I don't remember. From the heading of the pr, I assume that changes were accidental when trying to fix a checkstyle/findbugs issue. |
Thank you Sancar! @ulfjack care to send a PR? |
ulfjack
added a commit
to ulfjack/hazelcast
that referenced
this issue
Apr 6, 2020
Instead, keep the original URL object returned from the ClassLoader. This retains any associated URLStreamHandler with the URL, which allows the ClassLoader to return in-memory resources. As an alternative to this change, projects that want to use in-memory resources with Hazelcast could replace the URLStreamHandlerFactory, adding a custom scheme for in-memory resources. However, that seems a more invasive approach, with this change being strictly simpler. Fixes hazelcast#16846.
ulfjack
added a commit
to ulfjack/hazelcast
that referenced
this issue
Apr 9, 2020
Instead, keep the original URL object returned from the ClassLoader. This retains any associated URLStreamHandler with the URL, which allows the ClassLoader to return in-memory resources. As an alternative to this change, projects that want to use in-memory resources with Hazelcast could replace the URLStreamHandlerFactory, adding a custom scheme for in-memory resources. However, that seems a more invasive approach, with this change being strictly simpler. Fixes hazelcast#16846.
mmedenjak
pushed a commit
that referenced
this issue
Apr 14, 2020
Avoid round-tripping URLs through URI instances Instead, keep the original URL object returned from the ClassLoader. This retains any associated URLStreamHandler with the URL, which allows the ClassLoader to return in-memory resources. As an alternative to this change, projects that want to use in-memory resources with Hazelcast could replace the URLStreamHandlerFactory, adding a custom scheme for in-memory resources. However, that seems a more invasive approach, with this change being strictly simpler. Fixes #16846.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
good first issue
Good for newcomers
Source: Community
PR or issue was opened by a community user
Team: Core
Type: Defect
I'm trying to load Hazelcast from a custom ClassLoader that is not backed by a file. Hazelcast calls
ClassLoader.findResource
to read the corresponding service descriptions from the.jar
META-INF
directory (likeMETA-INF/services/com.hazelcast.instance.impl.NodeExtension
). Unfortunately, the Hazelcast classcom.hazelcast.internal.util.ServiceLoader
first converts the URL to a URI, and then converts it back to a URI. If I return a URL with an associated URLStreamHandler, then that gets lost in the conversion process (because URI doesn't support it).From the source code, it's not readily apparent why this is the case.
The only workaround seems to be to create a custom URLStreamHandlerFactory in the Jvm.
The text was updated successfully, but these errors were encountered: