Revert "Consistently name Groovy scripts with the same content"

This reverts commit d902012835.

Reverting this temporarily to see if this fixes hitting an assert in the
JDK during Groovy's classloading
This commit is contained in:
Lee Hinman 2015-07-22 11:15:57 -06:00
parent aba1ec4580
commit a33cfe4b11
1 changed files with 7 additions and 3 deletions

View File

@ -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;