Merge pull request #180 from tea-dragon/master

Fix 'allow unresolved' for at least two list cases
This commit is contained in:
Havoc Pennington 2014-12-27 13:35:34 -08:00
commit 51d94fc357
2 changed files with 15 additions and 2 deletions

View File

@ -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) {

View File

@ -1120,6 +1120,15 @@ class ConfigTest extends TestUtils {
assertTrue("after resolution, config is now resolved", resolved2.isResolved)
}
@Test
def allowUnresolvedDoesAllowUnresolvedArrayElements() {
val values = ConfigFactory.parseString("unknown = [someVal], known = 42")
val unresolved = ConfigFactory.parseString("concat = [${unknown}[]], sibling = [${unknown}, ${known}]")
unresolved.resolve(ConfigResolveOptions.defaults().setAllowUnresolved(true))
unresolved.withFallback(values).resolve()
unresolved.resolveWith(values)
}
@Test
def allowUnresolvedDoesAllowUnresolved() {
val values = ConfigFactory.parseString("{ foo = 1, bar = 2, m = 3, n = 4}")