Skip to content

Commit

Permalink
Only add split segments valid numeric indexes (#805)
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez authored Aug 29, 2022
1 parent 338f921 commit f7ac9b2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ private KeyMap<V> getNext(final String seg) {
return getOrCreateAny();
} else if (seg.endsWith("]")) {
int begin = seg.lastIndexOf('[');
if (begin != -1) {
if (begin != -1 && isValidIndex(seg, begin)) {
String index = seg.substring(begin + 1, seg.length() - 1);
String name = seg.substring(0, begin);
KeyMap<V> next;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ void putAllAny() {
void map() {
KeyMap<String> map = new KeyMap<>();
map.findOrAdd("map.roles.*[*]").putRootValue("foo");
map.findOrAdd("map.threadpool.config[customPool].id").putRootValue("customPool");

assertEquals("foo", map.findRootValue("map.roles.user[0]"));
assertEquals("customPool", map.findRootValue("map.threadpool.config[customPool].id"));
}
}

0 comments on commit f7ac9b2

Please sign in to comment.