Skip to content

Commit

Permalink
Delegate to wrapped map for toString in DynamicMap (#72048)
Browse files Browse the repository at this point in the history
This changes has DynamicMap delegate to its interally wrapped Map for toString to give better 
debugging information. This is particularly relevant to Debug.explain in Painless.
  • Loading branch information
jdconrad authored Apr 21, 2021
1 parent 2d3f171 commit 1e49d36
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
5 changes: 5 additions & 0 deletions server/src/main/java/org/elasticsearch/script/DynamicMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,9 @@ public Collection<Object> values() {
public Set<Entry<String, Object>> entrySet() {
return delegate.entrySet();
}

@Override
public String toString() {
return delegate.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,4 +199,13 @@ public void testParseFromObjectWrongParamsFormat() {
);
assertEquals("Value must be of type Map: [params]", exc.getMessage());
}

public void testDynamicMapToString() {
Map<String, Object> map = new HashMap<>();
map.put("long", 1L);
map.put("string", "value");
DynamicMap dm = new DynamicMap(map, Collections.emptyMap());
assertTrue(dm.toString().contains("string=value"));
assertTrue(dm.toString().contains("long=1"));
}
}

0 comments on commit 1e49d36

Please sign in to comment.