mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
Fix 'allow unresolved' for at least two list cases
lists did not respond well to cases where only some of their elements were resolved or even when none of them were resolved but one of their object identities happened to change. Previously this would throw a nasty 'bug or broken' exception so it seems unlikely to have unintended side effects.
This commit is contained in:
parent
5c464b3b5a
commit
3c6488fbc2
@ -98,7 +98,11 @@ final class SimpleConfigList extends AbstractConfigValue implements ConfigList,
|
||||
}
|
||||
|
||||
if (changed != null) {
|
||||
return new SimpleConfigList(origin(), changed, newResolveStatus);
|
||||
if (newResolveStatus != null) {
|
||||
return new SimpleConfigList(origin(), changed, newResolveStatus);
|
||||
} else {
|
||||
return new SimpleConfigList(origin(), changed);
|
||||
}
|
||||
} else {
|
||||
return this;
|
||||
}
|
||||
@ -122,7 +126,7 @@ final class SimpleConfigList extends AbstractConfigValue implements ConfigList,
|
||||
return context.resolve(v);
|
||||
}
|
||||
|
||||
}, ResolveStatus.RESOLVED);
|
||||
}, null /* don't force resolve status -- could be allowing unresolved */);
|
||||
} catch (NotPossibleToResolve e) {
|
||||
throw e;
|
||||
} catch (RuntimeException e) {
|
||||
|
@ -1120,9 +1120,10 @@ class ConfigTest extends TestUtils {
|
||||
|
||||
@Test
|
||||
def allowUnresolvedDoesAllowUnresolved() {
|
||||
val values = ConfigFactory.parseString("{ foo = 1, bar = 2, m = 3, n = 4}")
|
||||
val values = ConfigFactory.parseString("{ foo = 1, bar = 2, m = 3, n = 4, unknown = [someVal]}")
|
||||
assertTrue("config with no substitutions starts as resolved", values.isResolved)
|
||||
val unresolved = ConfigFactory.parseString("a = ${foo}, b = ${bar}, c { x = ${m}, y = ${n}, z = foo${m}bar }, alwaysResolveable=${alwaysValue}, alwaysValue=42")
|
||||
val unresolved = ConfigFactory.parseString(
|
||||
"l = [${unknown}[]], l2 = [${unknown}, ${alwaysValue}], a = ${foo}, b = ${bar}, c { x = ${m}, y = ${n}, z = foo${m}bar }, alwaysResolveable=${alwaysValue}, alwaysValue=42")
|
||||
assertFalse("config with substitutions starts as not resolved", unresolved.isResolved)
|
||||
|
||||
// resolve() by default throws with unresolveable substs
|
||||
|
Loading…
Reference in New Issue
Block a user