From 5cfe5e92ce174d4c51dbd222fed6b811f6f569eb Mon Sep 17 00:00:00 2001 From: Jonathan Shook Date: Tue, 31 May 2022 21:01:52 -0500 Subject: [PATCH] make parameter consumer consistent with protomap --- .../engine/api/templating/ParsedTemplateMap.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/virtdata-api/src/main/java/io/nosqlbench/engine/api/templating/ParsedTemplateMap.java b/virtdata-api/src/main/java/io/nosqlbench/engine/api/templating/ParsedTemplateMap.java index e087fc03a..0b3791a9d 100644 --- a/virtdata-api/src/main/java/io/nosqlbench/engine/api/templating/ParsedTemplateMap.java +++ b/virtdata-api/src/main/java/io/nosqlbench/engine/api/templating/ParsedTemplateMap.java @@ -228,7 +228,11 @@ public class ParsedTemplateMap implements LongFunction>, StaticFi } public T takeStaticValue(String field, Class classOfT) { - return (T) statics.remove(field); + if (statics.containsKey(field)) { + protomap.remove(field); + return (T) statics.remove(field); + } + return null; } /** @@ -317,6 +321,7 @@ public class ParsedTemplateMap implements LongFunction>, StaticFi public T takeStaticConfigOr(String name, T defaultValue) { if (statics.containsKey(name)) { Object value = statics.remove(name); + protomap.remove(name); return NBTypeConverter.convertOr(value, defaultValue); } for (Map cfgsource : cfgsources) { @@ -472,7 +477,7 @@ public class ParsedTemplateMap implements LongFunction>, StaticFi if (cfgsource.containsKey(name)) { Object object = cfgsource.get(name); if (type.isAssignableFrom(object.getClass())) { - return Optional.of((LongFunction) cfgsource.get(name)); + return Optional.of(l -> (V) cfgsource.get(name)); } else if (NBTypeConverter.canConvert(object, type)) { return Optional.of(l -> NBTypeConverter.convert(cfgsource.get(name), type)); } else {