-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
ResourcePatternHints should not be merged in a single json entry #29270
Comments
I want to help with this, but please advise on what is expected. ResourceHints hints = new ResourceHints();
hints.registerPattern(hint -> hint.includes("com/*").excludes("com/example/*"));
hints.registerPattern(hint -> hint.includes("com/example/*/all.properties").excludes("com/example/ignore/all.properties")); Currently, it produces: {
"resources": {
"includes": [
{ "pattern": "\\Q/\\E"},
{ "pattern": "\\Qcom/\\E.*"},
{ "pattern": "\\Qcom\\E"},
{ "pattern": "\\Qcom/example/\\E.*\\Q/all.properties\\E"},
{ "pattern": "\\Qcom/example\\E"}
],
"excludes": [
{ "pattern": "\\Qcom/example/\\E.*"},
{ "pattern": "\\Qcom/example/ignore/all.properties\\E"}
]
}
} Am I right that it's supposed to be the following way: {
"resources": {
"includes": [
{ "pattern": "\\Q/\\E"},
{ "pattern": "\\Qcom/\\E.*"},
{ "pattern": "\\Qcom\\E"},
],
"excludes": [
{ "pattern": "\\Qcom/example/\\E.*"},
{ "pattern": "\\Qcom/example/ignore/all.properties\\E"}
]
}
} I think it can be quite complicated in some cases to filter it out properly. However, a simple filter is possible - for example, if it's the same or if a particular "include" is of a particular pattern of some "exclude" - then remove this "include". Alsoб just for a note, here is the corresponding implementation in the graalvm: https://github.com/oracle/graal/pull/2912/files#diff-4b973ff5fd08418824ad1f4c7ce54a757b0641094f899f02a1c54fdc112739f2R263. It goes the same way as ResourceHintsPredicates.AggregatedResourcePatternHints, so making such filtering is better but not necessary. I meanб this ticket doesn't look like a bug to me (but probably, I'm missing smth). |
@bdshadow you are correct. I think the assumption made in #28977 was wrong. I think @philwebb thought that you could register an array of includes/excludes pair but, looking at the documentation it really is an array of includes and an array of excludes. As such, I believe the current behavior is correct based on that constraints. Thanks for bringing this up! |
No, I didn't think that, but I was worried that users might as Given that the API is out there and nobody seems to have hit the issue it looks like my fears were unfounded. |
Excludes will go away in #31340 as GraalVM will simplify support on the resource-config format. |
As reported by #28977
The
ResourcePatternHints
is a container forincludes
andexcludes
and multipleResourcePatternHints
can be registered. It's possible that callers may expect that these includes and excludes are related, however, when the JSON is written all excludes and all includes are included together. See ResourceHintsPredicates.AggregatedResourcePatternHints for an example of the flattening that needs to occur when using the pattern hints.The text was updated successfully, but these errors were encountered: