You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by sp...@apache.org on 2017/08/18 10:40:38 UTC
tinkerpop git commit: Fixed possible classcastexception in groovy
ScriptEngine
Repository: tinkerpop
Updated Branches:
refs/heads/tp32 ad1277653 -> 43f5afa07
Fixed possible classcastexception in groovy ScriptEngine
Minor adjustment to exceptions. Without this change you'd end up with a ClassCastExeption and error out, so this shouldn't be adding any new behavior. Logic is the same as before, without the possible failure condition CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/43f5afa0
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/43f5afa0
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/43f5afa0
Branch: refs/heads/tp32
Commit: 43f5afa0725c42bdde72049e5d88720bdce6e787
Parents: ad12776
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Thu Aug 17 15:04:44 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Thu Aug 17 15:04:44 2017 -0400
----------------------------------------------------------------------
.../groovy/jsr223/GremlinGroovyScriptEngine.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/43f5afa0/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
index d52e104..a74d4d9 100644
--- a/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
+++ b/gremlin-groovy/src/main/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngine.java
@@ -30,6 +30,7 @@ import groovy.lang.MissingMethodException;
import groovy.lang.MissingPropertyException;
import groovy.lang.Script;
import groovy.lang.Tuple;
+import org.apache.commons.lang.exception.ExceptionUtils;
import org.apache.tinkerpop.gremlin.groovy.CompilerCustomizerProvider;
import org.apache.tinkerpop.gremlin.groovy.DefaultImportCustomizerProvider;
import org.apache.tinkerpop.gremlin.groovy.EmptyImportCustomizerProvider;
@@ -580,7 +581,7 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
public CompiledScript compile(final String scriptSource) throws ScriptException {
try {
return new GroovyCompiledScript(this, getScriptClass(scriptSource));
- } catch (CompilationFailedException e) {
+ } catch (Exception e) {
throw new ScriptException(e);
}
}
@@ -733,11 +734,19 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
return classMap.stats().totalLoadTime();
}
- Class getScriptClass(final String script) throws CompilationFailedException {
+ Class getScriptClass(final String script) throws Exception {
try {
return classMap.get(script).get();
} catch (ExecutionException e) {
- throw ((CompilationFailedException)e.getCause());
+ final Throwable t = e.getCause();
+
+ // more often than not the cause is a compilation problem but there might be other failures that can
+ // occur in which case, just throw the ExecutionException as-is and let it bubble up as i'm not sure
+ // what the specific handling should be
+ if (t instanceof CompilationFailedException)
+ throw (CompilationFailedException) t;
+ else
+ throw e;
} catch (InterruptedException e) {
//This should never happen as the future should completed before it is returned to the us.
throw new AssertionError();