mirror of
https://github.com/lightbend/config.git
synced 2025-01-15 23:01:05 +08:00
Use the proper stack ordering when building a nested path in the Parser.
This commit is contained in:
parent
07c67aed2e
commit
366ab55582
@ -683,7 +683,9 @@ final class Parser {
|
||||
}
|
||||
|
||||
if (!pathStack.isEmpty()) {
|
||||
Path prefix = new Path(pathStack);
|
||||
// The stack is in reverse order (most recent first on the
|
||||
// iterator), so build the path from the reversed iterator.
|
||||
Path prefix = new Path(pathStack.descendingIterator());
|
||||
obj = obj.relativized(prefix);
|
||||
}
|
||||
|
||||
|
@ -35,10 +35,14 @@ final class Path {
|
||||
|
||||
// append all the paths in the list together into one path
|
||||
Path(List<Path> pathsToConcat) {
|
||||
if (pathsToConcat.isEmpty())
|
||||
this(pathsToConcat.iterator());
|
||||
}
|
||||
|
||||
// append all the paths in the iterator together into one path
|
||||
Path(Iterator<Path> i) {
|
||||
if (!i.hasNext())
|
||||
throw new ConfigException.BugOrBroken("empty path");
|
||||
|
||||
Iterator<Path> i = pathsToConcat.iterator();
|
||||
Path firstPath = i.next();
|
||||
this.first = firstPath.first;
|
||||
|
||||
|
@ -1029,6 +1029,10 @@ class ConfigTest extends TestUtils {
|
||||
assertEquals(3, resolved.getInt("foo.a.c"))
|
||||
assertEquals(5, resolved.getInt("foo.b"))
|
||||
assertEquals(10, resolved.getInt("foo.a.q"))
|
||||
|
||||
assertEquals(3, resolved.getInt("bar.nested.a.c"))
|
||||
assertEquals(5, resolved.getInt("bar.nested.b"))
|
||||
assertEquals(10, resolved.getInt("bar.nested.a.q"))
|
||||
}
|
||||
|
||||
@Test
|
||||
|
Loading…
Reference in New Issue
Block a user