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:
ian 2014-07-22 19:43:33 -04:00
parent 5c464b3b5a
commit 3c6488fbc2
2 changed files with 9 additions and 4 deletions

View File

@ -98,7 +98,11 @@ final class SimpleConfigList extends AbstractConfigValue implements ConfigList,
} }
if (changed != null) { 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 { } else {
return this; return this;
} }
@ -122,7 +126,7 @@ final class SimpleConfigList extends AbstractConfigValue implements ConfigList,
return context.resolve(v); return context.resolve(v);
} }
}, ResolveStatus.RESOLVED); }, null /* don't force resolve status -- could be allowing unresolved */);
} catch (NotPossibleToResolve e) { } catch (NotPossibleToResolve e) {
throw e; throw e;
} catch (RuntimeException e) { } catch (RuntimeException e) {

View File

@ -1120,9 +1120,10 @@ class ConfigTest extends TestUtils {
@Test @Test
def allowUnresolvedDoesAllowUnresolved() { 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) 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) assertFalse("config with substitutions starts as not resolved", unresolved.isResolved)
// resolve() by default throws with unresolveable substs // resolve() by default throws with unresolveable substs