Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id BF3E9200CED for ; Fri, 18 Aug 2017 12:40:41 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id BD81516C9E7; Fri, 18 Aug 2017 10:40:41 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1049316C9E6 for ; Fri, 18 Aug 2017 12:40:40 +0200 (CEST) Received: (qmail 35512 invoked by uid 500); 18 Aug 2017 10:40:39 -0000 Mailing-List: contact commits-help@tinkerpop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.apache.org Delivered-To: mailing list commits@tinkerpop.apache.org Received: (qmail 35503 invoked by uid 99); 18 Aug 2017 10:40:38 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 18 Aug 2017 10:40:38 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id C4412E053D; Fri, 18 Aug 2017 10:40:38 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: spmallette@apache.org To: commits@tinkerpop.apache.org Message-Id: <87125ddbf3c84fca854f918430ccbee3@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: tinkerpop git commit: Fixed possible classcastexception in groovy ScriptEngine Date: Fri, 18 Aug 2017 10:40:38 +0000 (UTC) archived-at: Fri, 18 Aug 2017 10:40:41 -0000 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 Authored: Thu Aug 17 15:04:44 2017 -0400 Committer: Stephen Mallette 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();