-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
I was validating a scenario where, if I provide a commit ID that is not present in the repository, the Config Client should use the second value from the property:
spring.cloud.config.label=${COMMIT_ID},${BRANCH}
Test 1
I passed the following commit ID from the Config Client to the Config Server:
COMMIT_ID=f7a5dafbe969da489f1282bc70f870a160a66c5f
In this case, the Config Server threw a RefNotFoundException, and the client then retried using the branch name. This behavior was expected.
Test 2
Next, I passed another non-existent commit ID:
COMMIT_ID=77a5dafbe969da489f1282bc70f870a160a66c5f
In this case, I received an IOException, and the Config Client failed to start.
So, even though both commit IDs are invalid and not present in the repository, they resulted in different exceptions — RefNotFoundException in one case and IOException in another.
Config Server Configuration
spring.cloud.config.server.git.uri=https://github.com/example-org/config-repo.git
spring.cloud.config.server.git.username=your-username
spring.cloud.config.server.git.password=your-password
spring.cloud.config.server.git.search-paths=app1/*
spring.cloud.config.server.default-label=development
spring.cloud.config.server.git.basedir=/tmp/config-repo
spring.cloud.config.server.git.clone-on-start=false
spring.cloud.config.server.git.refresh-rate=0
spring.cloud.config.server.git.skipSslValidation=false
spring.cloud.config.server.git.deleteUntrackedBranches=true
spring.cloud.config.server.git.force-pull=true
spring.cloud.config.server.git.pattern=*
Config Client Configuration
spring.application.name=service
spring.config.import=optional:configserver:${CONFIG_SERVER_URI}
spring.cloud.config.fail-fast=true
spring.cloud.config.label=${COMMIT_ID},${BRANCH}
spring.cloud.config.retry.max-attempts=5
spring.cloud.config.retry.max-interval=5000
spring.cloud.config.retry.initial-interval=2000
spring.cloud.config.retry.multiplier=1.5
Observation
Two different commit IDs that are both invalid led to different exception types:
RefNotFoundException— handled correctly, fallback to branch.IOException— caused client startup failure.
Why there are two behavior ?