-
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
Enable ThrowMissingRegistrationErrors with GraalVM >= 23.1 #36378
Draft
zakkak
wants to merge
4
commits into
quarkusio:main
Choose a base branch
from
zakkak:2023-10-10-enable-ThrowMissingRegistrationErrors
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f445bce
Do not discover properties resource in the classpath to avoid missing…
radcortez dd200e7
Catch `MissingReflectionRegistrationError` in loadConfigSources
zakkak a62c8d6
Enable ThrowMissingRegistrationErrors with GraalVM >= 23.1
zakkak c9bdb7b
TEST ME DON'T MERGE ME
zakkak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
core/runtime/src/main/java/io/quarkus/runtime/configuration/NativeConfigBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package io.quarkus.runtime.configuration; | ||
|
||
import static io.smallrye.config.PropertiesConfigSourceLoader.inFileSystem; | ||
|
||
import java.nio.file.Paths; | ||
|
||
import io.smallrye.config.SmallRyeConfigBuilder; | ||
|
||
/** | ||
* Do not register classpath resources lookup in native mode to avoid missing resources registration errors, which | ||
* became a strict check during native image execution. | ||
* <p> | ||
* Configuration coming from classpath resources is recoded during build time in a low ordinal source, so the | ||
* 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. | ||
*/ | ||
public class NativeConfigBuilder implements ConfigBuilder { | ||
@Override | ||
public SmallRyeConfigBuilder configBuilder(final SmallRyeConfigBuilder builder) { | ||
builder | ||
.setAddDefaultSources(false) | ||
.setAddSystemSources(true) | ||
.setAddPropertiesSources(false); | ||
|
||
builder.withSources(inFileSystem( | ||
Paths.get(System.getProperty("user.dir"), "config", "application.properties").toUri().toString(), 260, | ||
builder.getClassLoader())); | ||
|
||
return builder; | ||
} | ||
|
||
@Override | ||
public int priority() { | ||
return Integer.MIN_VALUE + 100; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...l/runtime/src/main/java/io/quarkus/config/yaml/runtime/YamlInFileSystemConfigBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package io.quarkus.config.yaml.runtime; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.eclipse.microprofile.config.spi.ConfigSourceProvider; | ||
|
||
import io.quarkus.runtime.configuration.ConfigBuilder; | ||
import io.smallrye.config.SmallRyeConfigBuilder; | ||
import io.smallrye.config.source.yaml.YamlConfigSourceLoader; | ||
|
||
public class YamlInFileSystemConfigBuilder implements ConfigBuilder { | ||
@Override | ||
public SmallRyeConfigBuilder configBuilder(final SmallRyeConfigBuilder builder) { | ||
// Removes Yaml source providers added by the ServiceLoader to avoid double registration | ||
List<ConfigSourceProvider> toRemove = new ArrayList<>(); | ||
for (ConfigSourceProvider sourceProvider : builder.getSourceProviders()) { | ||
if (sourceProvider instanceof YamlConfigSourceLoader) { | ||
toRemove.add(sourceProvider); | ||
} | ||
} | ||
builder.getSourceProviders().removeAll(toRemove); | ||
return builder.withSources(new YamlConfigSourceLoader.InFileSystem()); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I am afraid this change could break downstream code. I would put a package filter that handles only Quarkus classes and Quarkus-managed libraries in code that goes to users. Then, we can ask the users in the next release to add
--throw-missing-registration-errors=
to their build.We can use the unfiltered version for internal tests (ideally used with our dev builds). In tests, it is ideally used in combination with
-H:MissingRegistrationReportingMode=Exit
to make sure metadata is never missed.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.
Thanks for the input @vjovanov.
FYI when running without
-H:MissingRegistrationReportingMode=Exit
the Quarkus binary exits with error code 1 without printing anything.When adding
-H:MissingRegistrationReportingMode=Exit
I get to see the exception:My understanding is that Quarkus catches the exception at some point which results in the error message not being shown, yet it still fails.
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.
I would say the same. That is why we introduced
-H:MissingRegistrationReportingMode=Exit
.To speed up the migration you can run the programs with
-H:MissingRegistrationReportingMode=Warn
and it will only print the missing elements.