Skip to content

Commit 8a2ce42

Browse files
authored
Improve consistency of MergedApplicationConfig.kt (#3611)
Co-authored-by: David Bieregger <[email protected]>
1 parent d4ff13d commit 8a2ce42

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

ktor-server/ktor-server-core/jvmAndNix/src/io/ktor/server/config/MergedApplicationConfig.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ internal class MergedApplicationConfig(
4040
) : ApplicationConfig {
4141

4242
private val firstKeys by lazy { first.keys() }
43+
private val secondKeys by lazy { second.keys() }
4344

4445
override fun property(path: String): ApplicationConfigValue = when {
4546
firstKeys.contains(path) -> first.property(path)
@@ -53,17 +54,17 @@ internal class MergedApplicationConfig(
5354

5455
override fun config(path: String): ApplicationConfig {
5556
if (firstKeys.none { it.startsWith("$path.") }) return second.config(path)
56-
if (second.keys().none { it.startsWith("$path.") }) return first.config(path)
57+
if (secondKeys.none { it.startsWith("$path.") }) return first.config(path)
5758
return MergedApplicationConfig(first.config(path), second.config(path))
5859
}
5960

6061
override fun configList(path: String): List<ApplicationConfig> {
6162
val firstList = if (firstKeys.contains(path)) first.configList(path) else emptyList()
62-
val secondList = if (second.keys().contains(path)) second.configList(path) else emptyList()
63+
val secondList = if (secondKeys.contains(path)) second.configList(path) else emptyList()
6364
return firstList + secondList
6465
}
6566

66-
override fun keys(): Set<String> = firstKeys + second.keys()
67+
override fun keys(): Set<String> = firstKeys + secondKeys
6768

6869
override fun toMap(): Map<String, Any?> = second.toMap() + first.toMap()
6970
}

0 commit comments

Comments
 (0)