-
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
Open
radcortez
wants to merge
2
commits into
quarkusio:main
Choose a base branch
from
radcortez:disable-config-properties-scan
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.
Open
Changes from all commits
Commits
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
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.
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.