You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by ro...@apache.org on 2022/11/03 21:24:25 UTC
[pinot] branch master updated: [hotfix]groovy class cache leak (#9716)
This is an automated email from the ASF dual-hosted git repository.
rongr pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 9698b3e4dd [hotfix]groovy class cache leak (#9716)
9698b3e4dd is described below
commit 9698b3e4ddedec0a78aeca44f5cafd9148f44fad
Author: Rong Rong <ro...@apache.org>
AuthorDate: Thu Nov 3 14:24:17 2022 -0700
[hotfix]groovy class cache leak (#9716)
* groovy class cache needs to be clean up;
* downside is template cache reuse is not possible. but luckily we don't reuse template that often.
Co-authored-by: Rong Rong <ro...@startree.ai>
Co-authored-by: Xiaotian (Jackie) Jiang <17...@users.noreply.github.com>
---
.../main/java/org/apache/pinot/spi/utils/GroovyTemplateUtils.java | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/GroovyTemplateUtils.java b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/GroovyTemplateUtils.java
index 52f00b0ca6..26b5da90cb 100644
--- a/pinot-spi/src/main/java/org/apache/pinot/spi/utils/GroovyTemplateUtils.java
+++ b/pinot-spi/src/main/java/org/apache/pinot/spi/utils/GroovyTemplateUtils.java
@@ -18,6 +18,7 @@
*/
package org.apache.pinot.spi.utils;
+import groovy.lang.GroovyShell;
import groovy.text.SimpleTemplateEngine;
import java.io.IOException;
import java.time.Instant;
@@ -33,7 +34,8 @@ 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);
@@ -41,7 +43,9 @@ public class GroovyTemplateUtils {
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.resetLoadedClasses();
+ return templateRendered;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org