improve: config providers for yaml and properties logs only warning on missing file#3245
Open
csviri wants to merge 2 commits intooperator-framework:mainfrom
Open
improve: config providers for yaml and properties logs only warning on missing file#3245csviri wants to merge 2 commits intooperator-framework:mainfrom
csviri wants to merge 2 commits intooperator-framework:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves error handling in YAML and Properties config providers by changing from throwing an UncheckedIOException when a file doesn't exist to logging a warning and returning empty configuration. This makes the providers more suitable for dynamic configurations sourced from ConfigMaps.
Changes:
- Modified
YamlConfigProviderandPropertiesConfigProviderto check for file existence upfront and return empty collections instead of throwing exceptions - Added convenience String-based constructors to both providers that delegate to their Path-based counterparts
- Added logging to warn when configuration files are missing
- Updated corresponding tests to verify that missing files now return empty values instead of throwing exceptions
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| YamlConfigProvider.java | Added file existence check that returns empty Map and logs warning instead of throwing exception; added String constructor |
| PropertiesConfigProvider.java | Added file existence check that returns empty Properties and logs warning instead of throwing exception; added String constructor |
| YamlConfigProviderTest.java | Updated test to verify empty return value for missing file instead of exception |
| PropertiesConfigProviderTest.java | Updated test to verify empty return value for missing file instead of exception |
You can also share your feedback on Copilot code review. Take the survey.
...ork/src/main/java/io/javaoperatorsdk/operator/config/loader/provider/YamlConfigProvider.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/javaoperatorsdk/operator/config/loader/provider/PropertiesConfigProvider.java
Outdated
Show resolved
Hide resolved
...ork/src/main/java/io/javaoperatorsdk/operator/config/loader/provider/YamlConfigProvider.java
Outdated
Show resolved
Hide resolved
...c/main/java/io/javaoperatorsdk/operator/config/loader/provider/PropertiesConfigProvider.java
Outdated
Show resolved
Hide resolved
771300d to
f8d7205
Compare
…n missing file This it is easier to handle dynamic configurations coming from a ConfigMap Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
f8d7205 to
03636ac
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This it is easier to handle dynamic configurations coming from a ConfigMap
Signed-off-by: Attila Mészáros a_meszaros@apple.com