Support Reading CloudServices.config from File System and Classpath #944
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.
Support Reading Services Configuration from File System and Classpath
Issue
When deploying the application as a JAR (rather than a web application), it currently expects the service configuration files (
SERVICES_DEV_FILEandSERVICES_FILE) to be available only in the file system. If these files are missing, the application fails to load the configurations instead of checking if they exist in the JAR’s classpath.Additionally, if
SERVICES_DEV_FILEis found, the execution stops without attempting to loadSERVICES_FILE, which may contain additional configurations.Solution
This PR enhances the configuration loading mechanism to:
ClassLoader.getResourceAsStream.SERVICES_FILEis always attempted, even ifSERVICES_DEV_FILEis successfully loaded.Changes Made
Added
readFromClasspathmethod:ClassLoader.getResourceAsStreamto attempt reading files from the JAR classpath if they are missing in the file system.Modified
readServicesmethod:SERVICES_DEV_FILEfrom both file system and classpath.SERVICES_FILEis always attempted afterSERVICES_DEV_FILE, regardless of whether the first file was found or not.Refactored
loadFromFiletoloadFromStream:loadFromStreamto handle both file-based and classpath-based input streams.Improved error logging:
Expected Behavior After Merge
✔ If
SERVICES_DEV_FILEis found, it loads but does not preventSERVICES_FILEfrom loading.✔ If
SERVICES_FILEis missing in the file system, it will still be attempted from the JAR classpath.✔ Ensures configurations are correctly loaded even when packaged inside a JAR.
✔ Eliminates failures caused by missing configuration files in JAR deployments.
Testing
SERVICES_DEV_FILEandSERVICES_FILEexist in the file system → ✅ Both should load.SERVICES_DEV_FILEexists,SERVICES_FILEis missing → ✅ LoadsSERVICES_DEV_FILE, triesSERVICES_FILEin the classpath.Impact
🚀 Ready for review!