-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Do not discover properties resource in the classpath to avoid missing resources registration in native mode #44910
base: main
Are you sure you want to change the base?
Do not discover properties resource in the classpath to avoid missing resources registration in native mode #44910
Conversation
This comment has been minimized.
This comment has been minimized.
CI failures seem related |
Yes |
I was expecting more actually :) |
74e2236
to
8cbb860
Compare
This comment has been minimized.
This comment has been minimized.
🎊 PR Preview 43f9421 has been successfully built and deployed to https://quarkus-pr-main-44910-preview.surge.sh/version/main/guides/
|
This comment has been minimized.
This comment has been minimized.
8cbb860
to
784a1fe
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@radcortez what's the status of this PR, is it ready for review and merging? |
Yes, if you are happy with it :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I have a concern about this being a breaking change, see comments.
* configuration will still be available. If the users change the ordinals of the sources in runtime, it may | ||
* cause unexpected values to be returned by the config, but this has always been the case. The classpath configuration | ||
* resources were never registered in the native image. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this true?
In oracle/graal#10264 (reply in thread) we describe a scenario were using the classpath would work fine (assuming the user registers the resource for reflection and sets the ordinals accordingly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With our stuff yes, we never registered the resources. The configuration is just included in a class file and we discard the resources, which may cause the issue described in #44652 (comment), but this has been an issue since day one and until now we never got any complaints about it.
static final class Target_AbstractLocationConfigSourceLoader { | ||
@Substitute | ||
protected List<ConfigSource> tryClassPath(final URI uri, final int ordinal, final ClassLoader classLoader) { | ||
return Collections.emptyList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If what my previous comment is right, this is a breaking (for quite a corner case I admit) change, no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this could be a breaking change if a user has a custom source with a custom resource. If they are registering the resource manually they would need to process the file and generate some sort of representation (like us) for runtime.
Unfortunately, I don't see any good alternative. Having to forcely register all the resources is going to throw away all of our optimizations. If we leave it as is, you get the error that we are trying to prevent. (Well I guess we could add a try / catch there instead).
I still think it doesn't make sense to apply that validation to an API like ClassLoader#getResources
. That API never fails in JVM mode, no matter what you are looking for. Granted that you can obtain different results from JVM to native if the registrations are not done properly, but the native image shouldn't try to outsmart the library or integrator by changing API behaviours.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, I don't see any good alternative.
I am personally fine with this, since it's a corner case. I am not even sure we need to document this kind of "breakage".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@radcortez I went on with adding a try/catch. Please have a look.
… resources registration in native mode
Works around issue discussed in oracle/graal#10264 (reply in thread)
784a1fe
to
8733462
Compare
Status for workflow
|
Status for workflow
|
Disable automatic discovery of configuration resources in native mode.
While it has always been enabled, it didn't have any effect because we never registered the resources in the native image. The configuration still worked, because we recorded the configuration during build time.
I did try to disable it as well for JVM mode, but it is a bit more tricky:
Ideally, both JVM and native mode should be the same, but at the moment they're not. While this doesn't solve that particular issue, it should at least fix the missing registration warnings / errors without changing the current behaviour.
Alternate proposal to #42140.