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 2019/09/20 13:15:18 UTC

[tinkerpop] branch master updated (8599829 -> c164c76)

This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git.


    from 8599829  Merge branch 'tp34'
     new 79ce819  Return a 597 error code for lambda compilation problems.
     new 2e89be3  Merge branch 'tp33' into tp34
     new c164c76  Merge branch 'tp34'

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 CHANGELOG.asciidoc                                 |  1 +
 .../server/op/traversal/TraversalOpProcessor.java  |  7 +++++
 .../gremlin/server/GremlinServerIntegrateTest.java | 32 ++++++++++++++++++++--
 3 files changed, 38 insertions(+), 2 deletions(-)


[tinkerpop] 01/03: Return a 597 error code for lambda compilation problems.

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 79ce81933843280589813c2e482f7df4c4662d15
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Fri Sep 20 08:32:08 2019 -0400

    Return a 597 error code for lambda compilation problems.
    
    This is a more fine grained and accurate error now. Lambda compilation issues aren't really deserialization problems. CTR
---
 CHANGELOG.asciidoc                                 |  1 +
 .../server/op/traversal/TraversalOpProcessor.java  |  7 +++++
 .../gremlin/server/GremlinServerIntegrateTest.java | 32 ++++++++++++++++++++--
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index ccc4899..bf7ef39 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -35,6 +35,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 * Fixed potential for `NullPointerException` with empty identifiers in `GraphStep`.
 * Postponed the timing of transport creation to `connection.write` in Gremlin Python.
 * Made `EventStrategy` compatible with multi-valued properties.
+* Changed `TraversalOpProcessor` to throw a `SERVER_ERROR_SCRIPT_EVALUATION` (597) if lambdas don't compile.
 
 [[release-3-3-8]]
 === TinkerPop 3.3.8 (Release Date: August 5, 2019)
diff --git a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
index 36c6856..7b7dbdb 100644
--- a/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
+++ b/gremlin-server/src/main/java/org/apache/tinkerpop/gremlin/server/op/traversal/TraversalOpProcessor.java
@@ -55,6 +55,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import javax.script.Bindings;
+import javax.script.ScriptException;
 import javax.script.SimpleBindings;
 import java.lang.reflect.UndeclaredThrowableException;
 import java.util.ArrayList;
@@ -392,6 +393,12 @@ public class TraversalOpProcessor extends AbstractOpProcessor {
                 traversal = JavaTranslator.of(g).translate(bytecode);
             else
                 traversal = context.getGremlinExecutor().eval(bytecode, EMPTY_BINDINGS, lambdaLanguage.get(), traversalSourceName);
+        } catch (ScriptException ex) {
+            logger.error("Traversal contains a lambda that cannot be compiled", ex);
+            throw new OpProcessorException("Traversal contains a lambda that cannot be compiled",
+                    ResponseMessage.build(msg).code(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION)
+                            .statusMessage(ex.getMessage())
+                            .statusAttributeException(ex).create());
         } catch (Exception ex) {
             logger.error("Could not deserialize the Traversal instance", ex);
             throw new OpProcessorException("Could not deserialize the Traversal instance",
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
index 82e4f67..a8e7b3e 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
@@ -362,6 +362,34 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
     }
 
     @Test
+    public void shouldScriptEvaluationErrorForRemoteTraversal() throws Exception {
+        final GraphTraversalSource g = traversal().withRemote(conf);
+
+        try {
+            // tests bad lambda
+            g.inject(1).sideEffect(Lambda.consumer("(")).iterate();
+            fail("This traversal should not have executed since lambda can't be compiled");
+        } catch (Exception ex) {
+            final Throwable t = ex.getCause();
+            assertThat(t, instanceOf(ResponseException.class));
+            assertEquals(ResponseStatusCode.SERVER_ERROR_SCRIPT_EVALUATION, ((ResponseException) t).getResponseStatusCode());
+        }
+
+        // make a graph with a cycle in it to force a long run traversal
+        graphGetter.get().traversal().addV("person").as("p").addE("self").to("p").iterate();
+
+        try {
+            // tests an "unending" traversal
+            g.V().repeat(__.out()).until(__.outE().count().is(0)).iterate();
+            fail("This traversal should have timed out");
+        } catch (Exception ex) {
+            final Throwable t = ex.getCause();
+            assertThat(t, instanceOf(ResponseException.class));
+            assertEquals(ResponseStatusCode.SERVER_ERROR_TIMEOUT, ((ResponseException) t).getResponseStatusCode());
+        }
+    }
+
+    @Test
     public void shouldCloseChannelIfClientDoesntRespond() throws Exception {
         final SimpleClient client = TestClientFactory.createWebSocketClient();
         client.submit("1+1");
@@ -649,7 +677,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             cluster.close();
         }
     }
-    
+
     @Test
     public void shouldEnableSslAndClientCertificateAuthWithPkcs12() {
         final Cluster cluster = TestClientFactory.build().enableSsl(true).keyStore(P12_CLIENT_KEY).keyStorePassword(KEY_PASS)
@@ -709,7 +737,7 @@ public class GremlinServerIntegrateTest extends AbstractGremlinServerIntegration
             cluster.close();
         }
     }
-    
+
     @Test
     public void shouldEnableSslAndFailIfProtocolsDontMatch() {
         final Cluster cluster = TestClientFactory.build().enableSsl(true).keyStore(JKS_SERVER_KEY).keyStorePassword(KEY_PASS)


[tinkerpop] 02/03: Merge branch 'tp33' into tp34

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit 2e89be3b20fbcee291bb974df6bfe4f3a3dd522d
Merge: 2caf136 79ce819
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Fri Sep 20 08:33:37 2019 -0400

    Merge branch 'tp33' into tp34

 CHANGELOG.asciidoc                                 |  1 +
 .../server/op/traversal/TraversalOpProcessor.java  |  7 +++++
 .../gremlin/server/GremlinServerIntegrateTest.java | 32 ++++++++++++++++++++--
 3 files changed, 38 insertions(+), 2 deletions(-)



[tinkerpop] 03/03: Merge branch 'tp34'

Posted by sp...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

spmallette pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tinkerpop.git

commit c164c765fa632717d80cfb2dcb2b80e46ddeaf3d
Merge: 8599829 2e89be3
Author: Stephen Mallette <sp...@genoprime.com>
AuthorDate: Fri Sep 20 09:15:06 2019 -0400

    Merge branch 'tp34'

 CHANGELOG.asciidoc                                 |  1 +
 .../server/op/traversal/TraversalOpProcessor.java  |  7 +++++
 .../gremlin/server/GremlinServerIntegrateTest.java | 32 ++++++++++++++++++++--
 3 files changed, 38 insertions(+), 2 deletions(-)

diff --cc gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
index cc9d084,57f13e0..f0304f1
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinServerIntegrateTest.java
@@@ -590,8 -653,56 +618,8 @@@ public class GremlinServerIntegrateTes
              cluster.close();
          }
      }
-     
+ 
      @Test
 -    public void shouldEnableSslAndClientCertificateAuthWithLegacyPem() {
 -        final Cluster cluster = TestClientFactory.build().enableSsl(true)
 -                .keyCertChainFile(PEM_CLIENT_CRT).keyFile(PEM_CLIENT_KEY)
 -                .keyPassword(KEY_PASS).trustCertificateChainFile(PEM_SERVER_CRT).create();
 -        final Client client = cluster.connect();
 -
 -        try {
 -            assertEquals("test", client.submit("'test'").one().getString());
 -        } finally {
 -            cluster.close();
 -        }
 -    }
 -
 -    @Test
 -    public void shouldEnableSslAndClientCertificateAuthAndFailWithoutCertWithLegacyPem() {
 -        final Cluster cluster = TestClientFactory.build().enableSsl(true).keyStore(JKS_SERVER_KEY).keyStorePassword(KEY_PASS).sslSkipCertValidation(true).create();
 -        final Client client = cluster.connect();
 -
 -        try {
 -            client.submit("'test'").one();
 -            fail("Should throw exception because ssl client auth is enabled on the server but client does not have a cert");
 -        } catch(Exception x) {
 -            final Throwable root = ExceptionUtils.getRootCause(x);
 -            assertThat(root, instanceOf(NoHostAvailableException.class));
 -        } finally {
 -            cluster.close();
 -        }
 -    }
 -
 -    @Test
 -    public void shouldEnableSslAndClientCertificateAuthAndFailWithoutTrustedClientCertWithLegacyPem() {
 -        final Cluster cluster = TestClientFactory.build().enableSsl(true)
 -                .keyCertChainFile(PEM_CLIENT_CRT).keyFile(PEM_CLIENT_KEY)
 -                .keyPassword(KEY_PASS).trustCertificateChainFile(PEM_SERVER_CRT).create();
 -        final Client client = cluster.connect();
 -
 -        try {
 -            client.submit("'test'").one();
 -            fail("Should throw exception because ssl client auth is enabled on the server but does not trust client's cert");
 -        } catch(Exception x) {
 -            final Throwable root = ExceptionUtils.getRootCause(x);
 -            assertThat(root, instanceOf(NoHostAvailableException.class));
 -        } finally {
 -            cluster.close();
 -        }
 -    }
 -
 -    @Test
      public void shouldEnableSslAndClientCertificateAuthWithPkcs12() {
          final Cluster cluster = TestClientFactory.build().enableSsl(true).keyStore(P12_CLIENT_KEY).keyStorePassword(KEY_PASS)
                  .keyStoreType(KEYSTORE_TYPE_PKCS12).trustStore(P12_CLIENT_TRUST).trustStorePassword(KEY_PASS).create();