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/07/18 20:58:54 UTC
[1/3] tinkerpop git commit: Fixed bug in script engine which wasn't
registering globals
Repository: tinkerpop
Updated Branches:
refs/heads/master 2d30a76aa -> 005d2eb42
Fixed bug in script engine which wasn't registering globals
The secure configs for gremlin server weren't working. There was a change in the ScriptEngine plugin system that wasn't properly accounted for. Needed to register the types. Also added a little something to detect if this feature is even needed. That wasn't possible to do prior to 3.3.0. CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/4247e7df
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/4247e7df
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/4247e7df
Branch: refs/heads/master
Commit: 4247e7df370418510e202e566e27e26b7939f5b9
Parents: 2d30a76
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 18 16:14:52 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jul 18 16:14:52 2017 -0400
----------------------------------------------------------------------
CHANGELOG.asciidoc | 1 +
.../jsr223/GremlinGroovyScriptEngine.java | 38 +++++++++++++-------
2 files changed, 27 insertions(+), 12 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4247e7df/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 47668bb..176678c 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
TinkerPop 3.3.0 (Release Date: NOT OFFICIALLY RELEASED YET)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+* Detected if type checking was required in `GremlinGroovyScriptEngine` and disabled related infrastructure if not.
* Removed previously deprecated `DetachedEdge(Object,String,Map,Pair,Pair)` constructor.
* Removed previously deprecated `Bindings` constructor. It is now a private constructor.
* Removed previously deprecated `TraversalSource.withBindings()`.
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/4247e7df/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 fe12b1c..bc46d63 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.MissingPropertyException;
import groovy.lang.Script;
import groovy.lang.Tuple;
import org.apache.tinkerpop.gremlin.groovy.loaders.GremlinLoader;
+import org.apache.tinkerpop.gremlin.jsr223.ConcurrentBindings;
import org.apache.tinkerpop.gremlin.jsr223.CoreGremlinPlugin;
import org.apache.tinkerpop.gremlin.jsr223.Customizer;
import org.apache.tinkerpop.gremlin.jsr223.GremlinScriptContext;
@@ -65,13 +66,11 @@ import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Optional;
-import java.util.ServiceLoader;
import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
@@ -226,6 +225,11 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
private final long expectedCompilationTime;
/**
+ * There is no need to require type checking infrastructure if type checking is not enabled.
+ */
+ private final boolean typeCheckingEnabled;
+
+ /**
* Creates a new instance using no {@link Customizer}.
*/
public GremlinGroovyScriptEngine() {
@@ -233,6 +237,9 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
}
public GremlinGroovyScriptEngine(final Customizer... customizers) {
+ // initialize the global scope in case this scriptengine was instantiated outside of the ScriptEngineManager
+ setBindings(new ConcurrentBindings(), ScriptContext.GLOBAL_SCOPE);
+
final List<Customizer> listOfCustomizers = new ArrayList<>(Arrays.asList(customizers));
// always need this plugin for a scriptengine to be "Gremlin-enabled"
@@ -258,6 +265,9 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
expectedCompilationTime = compilationOptionsCustomizerProvider.isPresent() ?
compilationOptionsCustomizerProvider.get().getExpectedCompilationTime() : 5000;
+ typeCheckingEnabled = listOfCustomizers.stream()
+ .anyMatch(p -> p instanceof TypeCheckedGroovyCustomizer || p instanceof CompileStaticGroovyCustomizer);
+
// determine if interpreter mode should be enabled
interpreterModeEnabled = groovyCustomizers.stream()
.anyMatch(p -> p.getClass().equals(InterpreterModeGroovyCustomizer.class));
@@ -683,16 +693,20 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
}
private void registerBindingTypes(final ScriptContext context) {
- final Map<String, ClassNode> variableTypes = new HashMap<>();
- clearVarTypes();
-
- // use null for the classtype if the binding value itself is null - not fully sure if that is
- // a sound way to deal with that. didn't see a class type for null - maybe it should just be
- // unknown and be "Object". at least null is properly being accounted for now.
- context.getBindings(ScriptContext.ENGINE_SCOPE).forEach((k, v) ->
- variableTypes.put(k, null == v ? null : ClassHelper.make(v.getClass())));
-
- COMPILE_OPTIONS.get().put(COMPILE_OPTIONS_VAR_TYPES, variableTypes);
+ if (typeCheckingEnabled) {
+ final Map<String, ClassNode> variableTypes = new HashMap<>();
+ clearVarTypes();
+
+ // use null for the classtype if the binding value itself is null - not fully sure if that is
+ // a sound way to deal with that. didn't see a class type for null - maybe it should just be
+ // unknown and be "Object". at least null is properly being accounted for now.
+ context.getBindings(ScriptContext.GLOBAL_SCOPE).forEach((k, v) ->
+ variableTypes.put(k, null == v ? null : ClassHelper.make(v.getClass())));
+ context.getBindings(ScriptContext.ENGINE_SCOPE).forEach((k, v) ->
+ variableTypes.put(k, null == v ? null : ClassHelper.make(v.getClass())));
+
+ COMPILE_OPTIONS.get().put(COMPILE_OPTIONS_VAR_TYPES, variableTypes);
+ }
}
private static void clearVarTypes() {
[3/3] tinkerpop git commit: Merge branch 'tp32'
Posted by sp...@apache.org.
Merge branch 'tp32'
Conflicts:
gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/005d2eb4
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/005d2eb4
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/005d2eb4
Branch: refs/heads/master
Commit: 005d2eb42400d5f286c197f978cc241634956258
Parents: 4247e7d 2704245
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 18 16:58:46 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jul 18 16:58:46 2017 -0400
----------------------------------------------------------------------
.../server/GremlinDriverIntegrateTest.java | 26 --------------------
1 file changed, 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/005d2eb4/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------
diff --cc gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index 70e939e,6d4f236..4206cf9
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@@ -800,66 -764,6 +800,40 @@@ public class GremlinDriverIntegrateTes
}
@Test
+ public void shouldWorkWithGraphSONV3Serialization() throws Exception {
+ final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V3D0).create();
+ final Client client = cluster.connect();
+
+ final List<Result> r = client.submit("TinkerFactory.createModern().traversal().V(1)").all().join();
+ assertEquals(1, r.size());
+
+ final Vertex v = r.get(0).get(DetachedVertex.class);
+ assertEquals(1, v.id());
+ assertEquals("person", v.label());
+
+ assertEquals(2, IteratorUtils.count(v.properties()));
+ assertEquals("marko", v.value("name"));
+ assertEquals(29, Integer.parseInt(v.value("age").toString()));
+
+ cluster.close();
+ }
+
+ @Test
+ public void shouldWorkWithGraphSONExtendedV3Serialization() throws Exception {
+ final Cluster cluster = TestClientFactory.build().serializer(Serializers.GRAPHSON_V3D0).create();
+ final Client client = cluster.connect();
+
+ final Instant now = Instant.now();
+ final List<Result> r = client.submit("java.time.Instant.ofEpochMilli(" + now.toEpochMilli() + ")").all().join();
+ assertEquals(1, r.size());
+
+ final Instant then = r.get(0).get(Instant.class);
+ assertEquals(now, then);
+
+ cluster.close();
+ }
+
+ @Test
- @org.junit.Ignore("Can't seem to make this test pass consistently")
- public void shouldHandleRequestSentThatNeverReturns() throws Exception {
- final Cluster cluster = TestClientFactory.open();
- final Client client = cluster.connect();
-
- final ResultSet results = client.submit("Thread.sleep(10000); 'should-not-ever-get-back-coz-we-killed-the-server'");
-
- stopServer();
-
- // give the server a chance to kill everything
- Thread.sleep(1000);
-
- try {
- results.all().get(10000, TimeUnit.MILLISECONDS);
- fail("Server was stopped before the request could execute");
- } catch (TimeoutException toe) {
- fail("Should not have tossed a TimeOutException getting the result");
- } catch (Exception ex) {
- final Throwable cause = ExceptionUtils.getCause(ex);
- assertThat(cause.getMessage(), containsString("rejected from java.util.concurrent.ThreadPoolExecutor"));
- }
-
- cluster.close();
- }
-
- @Test
public void shouldFailClientSideWithTooLargeAResponse() {
final Cluster cluster = TestClientFactory.build().maxContentLength(1).create();
final Client client = cluster.connect();
[2/3] tinkerpop git commit: Removed server test that has been ignored
for a while
Posted by sp...@apache.org.
Removed server test that has been ignored for a while
The shouldHandleRequestSentThatNeverReturns has never behaved consistently in test environment even when the feature works fine under manual test. No point letting it hang around any longer. CTR
Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/2704245c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/2704245c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/2704245c
Branch: refs/heads/master
Commit: 2704245c2c64f0e1514aa4d6d2cd4c71f81c2511
Parents: 7c72e51
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Tue Jul 18 16:56:51 2017 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Tue Jul 18 16:56:51 2017 -0400
----------------------------------------------------------------------
.../server/GremlinDriverIntegrateTest.java | 26 --------------------
1 file changed, 26 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/2704245c/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
index 70ed643..6d4f236 100644
--- a/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
+++ b/gremlin-server/src/test/java/org/apache/tinkerpop/gremlin/server/GremlinDriverIntegrateTest.java
@@ -764,32 +764,6 @@ public class GremlinDriverIntegrateTest extends AbstractGremlinServerIntegration
}
@Test
- @org.junit.Ignore("Can't seem to make this test pass consistently")
- public void shouldHandleRequestSentThatNeverReturns() throws Exception {
- final Cluster cluster = TestClientFactory.open();
- final Client client = cluster.connect();
-
- final ResultSet results = client.submit("Thread.sleep(10000); 'should-not-ever-get-back-coz-we-killed-the-server'");
-
- stopServer();
-
- // give the server a chance to kill everything
- Thread.sleep(1000);
-
- try {
- results.all().get(10000, TimeUnit.MILLISECONDS);
- fail("Server was stopped before the request could execute");
- } catch (TimeoutException toe) {
- fail("Should not have tossed a TimeOutException getting the result");
- } catch (Exception ex) {
- final Throwable cause = ExceptionUtils.getCause(ex);
- assertThat(cause.getMessage(), containsString("rejected from java.util.concurrent.ThreadPoolExecutor"));
- }
-
- cluster.close();
- }
-
- @Test
public void shouldFailClientSideWithTooLargeAResponse() {
final Cluster cluster = TestClientFactory.build().maxContentLength(1).create();
final Client client = cluster.connect();