You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2022/11/03 19:05:16 UTC

[GitHub] [pinot] Jackie-Jiang commented on a diff in pull request #9716: [hotfix]groovy class cache leak

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: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org