problem: tries to connect to Redis even if specified as disabled
This commit is contained in:
@@ -35,19 +35,22 @@ class CacheConfigReader : YamlConfigReader(), ConfigReader<CacheConfig> {
|
||||
val config = CacheConfig()
|
||||
getMapping(node, "redis")?.let { node ->
|
||||
val redis = CacheConfig.Redis()
|
||||
getValueAsString(node, "host")?.let {
|
||||
redis.host = it
|
||||
val enabled = getValueAsBool(node, "enabled") ?: true
|
||||
if (enabled) {
|
||||
getValueAsString(node, "host")?.let {
|
||||
redis.host = it
|
||||
}
|
||||
getValueAsInt(node, "port")?.let {
|
||||
redis.port = it
|
||||
}
|
||||
getValueAsInt(node, "db")?.let {
|
||||
redis.db = it
|
||||
}
|
||||
getValueAsString(node, "password")?.let {
|
||||
redis.password = it
|
||||
}
|
||||
config.redis = redis
|
||||
}
|
||||
getValueAsInt(node, "port")?.let {
|
||||
redis.port = it
|
||||
}
|
||||
getValueAsInt(node, "db")?.let {
|
||||
redis.db = it
|
||||
}
|
||||
getValueAsString(node, "password")?.let {
|
||||
redis.password = it
|
||||
}
|
||||
config.redis = redis
|
||||
}
|
||||
if (config.redis == null) {
|
||||
return null
|
||||
|
||||
@@ -36,4 +36,15 @@ class CacheConfigReaderSpec extends Specification {
|
||||
password == "HelloWorld!1"
|
||||
}
|
||||
}
|
||||
|
||||
def "Read disabled"() {
|
||||
setup:
|
||||
def config = this.class.getClassLoader().getResourceAsStream("cache-redis-disabled.yaml")
|
||||
when:
|
||||
def act = reader.read(config)
|
||||
|
||||
then:
|
||||
//later may be not null if we support something else besides Redis
|
||||
act == null
|
||||
}
|
||||
}
|
||||
|
||||
7
src/test/resources/cache-redis-disabled.yaml
Normal file
7
src/test/resources/cache-redis-disabled.yaml
Normal file
@@ -0,0 +1,7 @@
|
||||
cache:
|
||||
redis:
|
||||
enabled: false
|
||||
host: redis-master
|
||||
port: 1234
|
||||
db: 5
|
||||
password: HelloWorld!1
|
||||
Reference in New Issue
Block a user