Close Mutability in TemplateDict map_each evaluation
Mutability instances must be wrapped in try-with-resource blocks outside
of test code.
Closes
@@ -101,8 +101,8 @@ public class TemplateDict implements TemplateDictApi {
@Override
public String getValue() throws EvalException {
- StarlarkThread execThread =
- new StarlarkThread(Mutability.create("expand_template"), semantics);
+ try (Mutability mutability = Mutability.create("expand_template")) {
+ StarlarkThread execThread = new StarlarkThread(mutability, semantics);
ImmutableList<?> values = valuesSet.toList();
List<String> parts = new ArrayList<>(values.size());
for (Object val : values) {
@@ -123,10 +123,12 @@ public class TemplateDict implements TemplateDictApi {
Starlark.type(ret), getKey());
} catch (InterruptedException e) {
// Report the error to the user, but the stack trace is not of use to them
- throw Starlark.errorf("Could not evaluate substitution for %s: %s", val, e.getMessage());
+ throw Starlark.errorf(
+ "Could not evaluate substitution for %s: %s", val, e.getMessage());
}
}
return Joiner.on(joinWith).join(parts);
}
}
}
+}
