improve: config providers for yaml and properties logs only warning on missing file by csviri · Pull Request #3245 · operator-framework/java-operator-sdk
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.