Jackie-Jiang commented on code in PR #9716:
URL: https://github.com/apache/pinot/pull/9716#discussion_r1013300016
##########
pinot-spi/src/main/java/org/apache/pinot/spi/utils/GroovyTemplateUtils.java:
##########
@@ -33,15 +34,18 @@ public class GroovyTemplateUtils {
private GroovyTemplateUtils() {
}
- private static final SimpleTemplateEngine GROOVY_TEMPLATE_ENGINE = new
SimpleTemplateEngine();
+ private static final GroovyShell GROOVY_SHELL = new GroovyShell();
+ private static final SimpleTemplateEngine GROOVY_TEMPLATE_ENGINE = new
SimpleTemplateEngine(GROOVY_SHELL);
private static final DateTimeFormatter DATE_FORMAT =
DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneOffset.UTC);
public static String renderTemplate(String template, Map<String, Object>
newContext)
throws IOException, ClassNotFoundException {
Map<String, Object> contextMap = getDefaultContextMap();
contextMap.putAll(newContext);
- return
GROOVY_TEMPLATE_ENGINE.createTemplate(template).make(contextMap).toString();
+ String templateRendered =
GROOVY_TEMPLATE_ENGINE.createTemplate(template).make(contextMap).toString();
+ GROOVY_SHELL.getClassLoader().clearCache();
Review Comment:
(nit)
```suggestion
GROOVY_SHELL.resetLoadedClasses();
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]