Skip to content

The Unified and Autonomous Development Platform

chore: Improved GroovyUtils

Robin Shen63d2b37b880e
diff --git a/server-core/src/main/java/io/onedev/server/util/GroovyUtils.java b/server-core/src/main/java/io/onedev/server/util/GroovyUtils.java
index f1523bd6a6..5849fc5ea6 100644
--- a/server-core/src/main/java/io/onedev/server/util/GroovyUtils.java
+++ b/server-core/src/main/java/io/onedev/server/util/GroovyUtils.java
@@ -123,8 +123,10 @@ public class GroovyUtils {
}
public static String evalTemplate(String template, Map<String, Object> bindings) {
+ // Make a copy of the bindings as the template engine will modify the bindings
+ var bindingsCopy = new HashMap<>(bindings);
try {
- return new SimpleTemplateEngine().createTemplate(template).make(bindings).toString();
+ return new SimpleTemplateEngine().createTemplate(template).make(bindingsCopy).toString();
} catch (CompilationFailedException | ClassNotFoundException | IOException e) {
throw new RuntimeException(e);
}