From a33cfe4b11c55652eb04980664e0d2d973903f93 Mon Sep 17 00:00:00 2001 From: Lee Hinman Date: Wed, 22 Jul 2015 11:15:57 -0600 Subject: [PATCH] Revert "Consistently name Groovy scripts with the same content" This reverts commit d902012835916179e0bb86890e7898cc30aef70a. Reverting this temporarily to see if this fixes hitting an assert in the JDK during Groovy's classloading --- .../script/groovy/GroovyScriptEngineService.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java b/core/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java index 17c4284f714..683ffc58f0f 100644 --- a/core/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java +++ b/core/src/main/java/org/elasticsearch/script/groovy/GroovyScriptEngineService.java @@ -19,8 +19,6 @@ package org.elasticsearch.script.groovy; -import com.google.common.base.Charsets; -import com.google.common.hash.Hashing; import groovy.lang.Binding; import groovy.lang.GroovyClassLoader; import groovy.lang.Script; @@ -51,6 +49,7 @@ import java.io.IOException; import java.math.BigDecimal; import java.util.HashMap; import java.util.Map; +import java.util.concurrent.atomic.AtomicLong; /** * Provides the infrastructure for Groovy as a scripting language for Elasticsearch @@ -58,6 +57,7 @@ import java.util.Map; public class GroovyScriptEngineService extends AbstractComponent implements ScriptEngineService { public static final String NAME = "groovy"; + private final AtomicLong counter = new AtomicLong(); private final GroovyClassLoader loader; @Inject @@ -111,7 +111,7 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri @Override public Object compile(String script) { try { - return loader.parseClass(script, Hashing.sha1().hashString(script, Charsets.UTF_8).toString()); + return loader.parseClass(script, generateScriptName()); } catch (Throwable e) { if (logger.isTraceEnabled()) { logger.trace("exception compiling Groovy script:", e); @@ -190,6 +190,10 @@ public class GroovyScriptEngineService extends AbstractComponent implements Scri return value; } + private String generateScriptName() { + return "Script" + counter.incrementAndGet() + ".groovy"; + } + public static final class GroovyScript implements ExecutableScript, LeafSearchScript { private final CompiledScript compiledScript;