You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tinkerpop.apache.org by dk...@apache.org on 2016/09/29 09:44:46 UTC

[1/6] tinkerpop git commit: fixed conf dir references [Forced Update!]

Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1158 041b9bb9b -> 9e0244ef4 (forced update)


fixed conf dir references


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/3cbd3719
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/3cbd3719
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/3cbd3719

Branch: refs/heads/TINKERPOP-1158
Commit: 3cbd3719084e5dcbb9b470228bd6a40e6d050478
Parents: 33225c5
Author: Robert Dale <ro...@gmail.com>
Authored: Mon Sep 26 11:01:53 2016 -0400
Committer: Robert Dale <ro...@gmail.com>
Committed: Tue Sep 27 20:42:15 2016 -0400

----------------------------------------------------------------------
 docs/src/reference/gremlin-applications.asciidoc | 4 ++--
 gremlin-console/src/main/bin/gremlin.sh          | 4 ++--
 gremlin-driver/src/main/bin/config-eval.sh       | 4 ++--
 gremlin-driver/src/main/bin/profile-driver.sh    | 4 ++--
 gremlin-server/src/main/bin/gremlin-server.sh    | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3cbd3719/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index cedd98f..7e827f1 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -775,7 +775,7 @@ Configuring
 ~~~~~~~~~~~
 
 As mentioned earlier, Gremlin Server is configured though a YAML file.  By default, Gremlin Server will look for a
-file called `config/gremlin-server.yaml` to configure itself on startup.  To override this default, supply the file
+file called `conf/gremlin-server.yaml` to configure itself on startup.  To override this default, supply the file
 to use to `bin/gremlin-server.sh` as in:
 
 [source,text]
@@ -920,7 +920,7 @@ Cluster cluster = Cluster.build().credentials("stephen", "password")
                                  .enableSsl(true).create();
 
 If connecting with Gremlin Console, which utilizes `gremlin-driver` for remote script execution, use the provided
-`config/remote-secure.yaml` file when defining the remote.  That file contains configuration for the username and
+`conf/remote-secure.yaml` file when defining the remote.  That file contains configuration for the username and
 password as well as enablement of SSL from the client side.
 
 Similarly, Gremlin Server can be configured for REST and security.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3cbd3719/gremlin-console/src/main/bin/gremlin.sh
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/bin/gremlin.sh b/gremlin-console/src/main/bin/gremlin.sh
index 84ba8179..fe28773 100755
--- a/gremlin-console/src/main/bin/gremlin.sh
+++ b/gremlin-console/src/main/bin/gremlin.sh
@@ -36,11 +36,11 @@ fi
 
 case `uname` in
   CYGWIN*)
-    CP="`dirname $0`"/../config
+    CP="`dirname $0`"/../conf
     CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /;/g')
     ;;
   *)
-    CP="`dirname $0`"/../config
+    CP="`dirname $0`"/../conf
     CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /:/g')
 esac
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3cbd3719/gremlin-driver/src/main/bin/config-eval.sh
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/bin/config-eval.sh b/gremlin-driver/src/main/bin/config-eval.sh
index c55ebf5..764d732 100644
--- a/gremlin-driver/src/main/bin/config-eval.sh
+++ b/gremlin-driver/src/main/bin/config-eval.sh
@@ -20,11 +20,11 @@
 #
 case `uname` in
   CYGWIN*)
-    CP="`dirname $0`"/../config/
+    CP="`dirname $0`"/../conf/
     CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /;/g')
     ;;
   *)
-    CP="`dirname $0`"/../config/
+    CP="`dirname $0`"/../conf/
     CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /:/g')
 esac
 #echo $CP

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3cbd3719/gremlin-driver/src/main/bin/profile-driver.sh
----------------------------------------------------------------------
diff --git a/gremlin-driver/src/main/bin/profile-driver.sh b/gremlin-driver/src/main/bin/profile-driver.sh
index ce747e5..7b4ac1b 100644
--- a/gremlin-driver/src/main/bin/profile-driver.sh
+++ b/gremlin-driver/src/main/bin/profile-driver.sh
@@ -20,11 +20,11 @@
 #
 case `uname` in
   CYGWIN*)
-    CP="`dirname $0`"/../config/
+    CP="`dirname $0`"/../conf/
     CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /;/g')
     ;;
   *)
-    CP="`dirname $0`"/../config/
+    CP="`dirname $0`"/../conf/
     CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /:/g')
 esac
 #echo $CP

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/3cbd3719/gremlin-server/src/main/bin/gremlin-server.sh
----------------------------------------------------------------------
diff --git a/gremlin-server/src/main/bin/gremlin-server.sh b/gremlin-server/src/main/bin/gremlin-server.sh
index a82f73f..fcede2b 100755
--- a/gremlin-server/src/main/bin/gremlin-server.sh
+++ b/gremlin-server/src/main/bin/gremlin-server.sh
@@ -20,11 +20,11 @@
 #
 case `uname` in
   CYGWIN*)
-    CP="`dirname $0`"/../config/
+    CP="`dirname $0`"/../conf/
     CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /;/g')
     ;;
   *)
-    CP="`dirname $0`"/../config/
+    CP="`dirname $0`"/../conf/
     CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /:/g')
 esac
 #echo $CP


[2/6] tinkerpop git commit: Added .glv to rat exclusions and gitignore

Posted by dk...@apache.org.
Added .glv to rat exclusions and gitignore

While tp31 has no knowledge of this file, switching branches leaves it hanging around which causes problems on builds and such. CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/14708fef
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/14708fef
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/14708fef

Branch: refs/heads/TINKERPOP-1158
Commit: 14708fefcba5528c58f7733d2bda9cd478d92b0a
Parents: 33225c5
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Sun Sep 25 17:13:48 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Sep 28 11:05:03 2016 -0400

----------------------------------------------------------------------
 .gitignore | 1 +
 pom.xml    | 1 +
 2 files changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14708fef/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index f4779c5..a493d4d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,4 @@ _bsp/
 doc/out
 docs/*.asciidoc
 ext/
+.glv
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/14708fef/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 2b58f6b..a09a8c2 100644
--- a/pom.xml
+++ b/pom.xml
@@ -285,6 +285,7 @@ limitations under the License.
                         <exclude>**/src/main/static/**</exclude>
                         <exclude>**/_bsp/**</exclude>
                         <exclude>DEPENDENCIES</exclude>
+                        <exclude>**/.glv</exclude>
                     </excludes>
                     <licenses>
                         <license implementation="org.apache.rat.analysis.license.ApacheSoftwareLicense20"/>


[3/6] tinkerpop git commit: TINKERPOP-1478 Fixed memory leak and proper redirection of output in GremlinGroovyScriptEngine

Posted by dk...@apache.org.
TINKERPOP-1478 Fixed memory leak and proper redirection of output in GremlinGroovyScriptEngine

These were bugs identified in Groovy and fixed some time ago, but given that GremlinGroovyScriptEngine is based on that class and doesn't directly use it, those fixes were never in place for it. CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/762f6b22
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/762f6b22
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/762f6b22

Branch: refs/heads/TINKERPOP-1158
Commit: 762f6b229925d407390e78d587ef98863205c870
Parents: 14708fe
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 28 12:48:26 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Sep 28 12:48:26 2016 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |   1 +
 .../src/reference/gremlin-applications.asciidoc |  25 +++-
 .../jsr223/GremlinGroovyScriptEngine.java       | 140 ++++++++++---------
 .../jsr223/GremlinGroovyScriptEngineTest.java   |  69 ++++++++-
 4 files changed, 162 insertions(+), 73 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/762f6b22/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 4b39cc7..d0aa8e8 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -26,6 +26,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 TinkerPop 3.1.5 (Release Date: NOT OFFICIALLY RELEASED YET)
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 
+* Fixed output redirection and potential memory leak in `GremlinGroovyScriptEngine`.
 * Corrected naming of `g_withPath_V_asXaX_out_out_mapXa_name_it_nameX` and `g_withPath_V_asXaX_out_mapXa_nameX` in `MapTest`.
 * Improved session cleanup when a close is triggered by the client.
 * Removed the `appveyor.yml` file as the AppVeyor build is no longer enabled by Apache Infrastructure.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/762f6b22/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/reference/gremlin-applications.asciidoc b/docs/src/reference/gremlin-applications.asciidoc
index cedd98f..d8b891e 100644
--- a/docs/src/reference/gremlin-applications.asciidoc
+++ b/docs/src/reference/gremlin-applications.asciidoc
@@ -1309,12 +1309,12 @@ client.submit("[1,2,3,x]", params);
 Cache Management
 ^^^^^^^^^^^^^^^^
 
-If Gremlin Server processes a large number of unique scripts, the cache will grow beyond the memory available to
-Gremlin Server and an `OutOfMemoryError` will loom.  Script parameterization goes a long way to solving this problem
-and running out of memory should not be an issue for those cases.  If it is a problem or if there is no script
-parameterization due to a given use case (perhaps using with use of <<sessions,sessions>>), it is possible to better
-control the nature of the script cache from the client side, by issuing scripts with a parameter to help define how
-the garbage collector should treat the references.
+If Gremlin Server processes a large number of unique scripts, the global function cache will grow beyond the memory
+available to Gremlin Server and an `OutOfMemoryError` will loom.  Script parameterization goes a long way to solving
+this problem and running out of memory should not be an issue for those cases.  If it is a problem or if there is no
+script parameterization due to a given use case (perhaps using with use of <<sessions,sessions>>), it is possible to
+better control the nature of the global function cache from the client side, by issuing scripts with a parameter to
+help define how the garbage collector should treat the references.
 
 The parameter is called `#jsr223.groovy.engine.keep.globals` and has four options:
 
@@ -1324,9 +1324,20 @@ The parameter is called `#jsr223.groovy.engine.keep.globals` and has four option
 * `phantom` - removed immediately after being evaluated by the `ScriptEngine`.
 
 By specifying an option other than `hard`, an `OutOfMemoryError` in Gremlin Server should be avoided.  Of course,
-this approach will come with the downside that compiled scripts could be garbage collected and thus removed from the
+this approach will come with the downside that functions could be garbage collected and thus removed from the
 cache, forcing Gremlin Server to recompile later if that script is later encountered.
 
+[source,java]
+----
+Cluster cluster = Cluster.open();
+Client client = cluster.connect();
+
+Map<String,Object> params = new HashMap<>();
+params.put("x",4);
+params.put("#jsr223.groovy.engine.keep.globals", "soft");
+client.submit("[1,2,3,x]", params);
+----
+
 [[sessions]]
 Considering Sessions
 ^^^^^^^^^^^^^^^^^^^^

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/762f6b22/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 ca129c6..acc7f90 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
@@ -46,7 +46,6 @@ import org.codehaus.groovy.jsr223.GroovyScriptEngineImpl;
 import org.codehaus.groovy.runtime.InvokerHelper;
 import org.codehaus.groovy.runtime.MetaClassHelper;
 import org.codehaus.groovy.runtime.MethodClosure;
-import org.codehaus.groovy.syntax.SyntaxException;
 import org.codehaus.groovy.util.ReferenceBundle;
 
 import javax.script.Bindings;
@@ -385,8 +384,6 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl implements
             final Class clazz = getScriptClass(script);
             if (null == clazz) throw new ScriptException("Script class is null");
             return eval(clazz, context);
-        } catch (SyntaxException e) {
-            throw new ScriptException(e.getMessage(), e.getSourceLocator(), e.getLine());
         } catch (Exception e) {
             throw new ScriptException(e);
         }
@@ -422,9 +419,7 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl implements
     public CompiledScript compile(final String scriptSource) throws ScriptException {
         try {
             return new GroovyCompiledScript(this, getScriptClass(scriptSource));
-        } catch (SyntaxException e) {
-            throw new ScriptException(e.getMessage(), e.getSourceLocator(), e.getLine());
-        } catch (IOException | CompilationFailedException e) {
+        } catch (CompilationFailedException e) {
             throw new ScriptException(e);
         }
     }
@@ -463,7 +458,7 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl implements
         return makeInterface(thiz, clazz);
     }
 
-    Class getScriptClass(final String script) throws SyntaxException, CompilationFailedException, IOException {
+    Class getScriptClass(final String script) throws CompilationFailedException {
         Class clazz = classMap.get(script);
         if (clazz != null) return clazz;
 
@@ -477,23 +472,33 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl implements
     }
 
     Object eval(final Class scriptClass, final ScriptContext context) throws ScriptException {
-        context.setAttribute("context", context, ScriptContext.ENGINE_SCOPE);
-        final Writer writer = context.getWriter();
-        context.setAttribute("out", writer instanceof PrintWriter ? writer : new PrintWriter(writer), ScriptContext.ENGINE_SCOPE);
-        final Binding binding = new Binding() {
+        final Binding binding = new Binding(context.getBindings(ScriptContext.ENGINE_SCOPE)) {
             @Override
-            public Object getVariable(final String name) {
+            public Object getVariable(String name) {
                 synchronized (context) {
-                    final int scope = context.getAttributesScope(name);
+                    int scope = context.getAttributesScope(name);
                     if (scope != -1) {
                         return context.getAttribute(name, scope);
                     }
-                    throw new MissingPropertyException(name, getClass());
+                    // Redirect script output to context writer, if out var is not already provided
+                    if ("out".equals(name)) {
+                        final Writer writer = context.getWriter();
+                        if (writer != null) {
+                            return (writer instanceof PrintWriter) ?
+                                    (PrintWriter) writer :
+                                    new PrintWriter(writer, true);
+                        }
+                    }
+                    // Provide access to engine context, if context var is not already provided
+                    if ("context".equals(name)) {
+                        return context;
+                    }
                 }
+                throw new MissingPropertyException(name, getClass());
             }
 
             @Override
-            public void setVariable(final String name, final Object value) {
+            public void setVariable(String name, Object value) {
                 synchronized (context) {
                     int scope = context.getAttributesScope(name);
                     if (scope == -1) {
@@ -505,67 +510,72 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl implements
         };
 
         try {
-            final Script scriptObject = InvokerHelper.createScript(scriptClass, binding);
-            for (Method m : scriptClass.getMethods()) {
-                final String name = m.getName();
-                globalClosures.put(name, new MethodClosure(scriptObject, name));
-            }
+            // if this class is not an instance of Script, it's a full-blown class then simply return that class
+            if (!Script.class.isAssignableFrom(scriptClass)) {
+                return scriptClass;
+            } else {
+                final Script scriptObject = InvokerHelper.createScript(scriptClass, binding);
+                for (Method m : scriptClass.getMethods()) {
+                    final String name = m.getName();
+                    globalClosures.put(name, new MethodClosure(scriptObject, name));
+                }
 
-            final MetaClass oldMetaClass = scriptObject.getMetaClass();
-            scriptObject.setMetaClass(new DelegatingMetaClass(oldMetaClass) {
-                @Override
-                public Object invokeMethod(final Object object, final String name, final Object args) {
-                    if (args == null) {
-                        return invokeMethod(object, name, MetaClassHelper.EMPTY_ARRAY);
-                    } else if (args instanceof Tuple) {
-                        return invokeMethod(object, name, ((Tuple) args).toArray());
-                    } else if (args instanceof Object[]) {
-                        return invokeMethod(object, name, (Object[]) args);
-                    } else {
-                        return invokeMethod(object, name, new Object[]{args});
+                final MetaClass oldMetaClass = scriptObject.getMetaClass();
+                scriptObject.setMetaClass(new DelegatingMetaClass(oldMetaClass) {
+                    @Override
+                    public Object invokeMethod(final Object object, final String name, final Object args) {
+                        if (args == null) {
+                            return invokeMethod(object, name, MetaClassHelper.EMPTY_ARRAY);
+                        } else if (args instanceof Tuple) {
+                            return invokeMethod(object, name, ((Tuple) args).toArray());
+                        } else if (args instanceof Object[]) {
+                            return invokeMethod(object, name, (Object[]) args);
+                        } else {
+                            return invokeMethod(object, name, new Object[]{args});
+                        }
                     }
-                }
 
-                @Override
-                public Object invokeMethod(final Object object, final String name, final Object args[]) {
-                    try {
-                        return super.invokeMethod(object, name, args);
-                    } catch (MissingMethodException mme) {
-                        return callGlobal(name, args, context);
+                    @Override
+                    public Object invokeMethod(final Object object, final String name, final Object args[]) {
+                        try {
+                            return super.invokeMethod(object, name, args);
+                        } catch (MissingMethodException mme) {
+                            return callGlobal(name, args, context);
+                        }
                     }
-                }
 
-                @Override
-                public Object invokeStaticMethod(final Object object, final String name, final Object args[]) {
-                    try {
-                        return super.invokeStaticMethod(object, name, args);
-                    } catch (MissingMethodException mme) {
-                        return callGlobal(name, args, context);
+                    @Override
+                    public Object invokeStaticMethod(final Object object, final String name, final Object args[]) {
+                        try {
+                            return super.invokeStaticMethod(object, name, args);
+                        } catch (MissingMethodException mme) {
+                            return callGlobal(name, args, context);
+                        }
                     }
-                }
-            });
+                });
 
-            final Object o = scriptObject.run();
+                final Object o = scriptObject.run();
 
-            // if interpreter mode is enable then local vars of the script are promoted to engine scope bindings.
-            if (interpreterModeEnabled) {
-                final Map<String, Object> localVars = (Map<String, Object>) context.getAttribute(COLLECTED_BOUND_VARS_MAP_VARNAME);
-                if (localVars != null) {
-                    localVars.entrySet().forEach(e -> {
-                        // closures need to be cached for later use
-                        if (e.getValue() instanceof Closure)
-                            globalClosures.put(e.getKey(), (Closure) e.getValue());
+                // if interpreter mode is enable then local vars of the script are promoted to engine scope bindings.
+                if (interpreterModeEnabled) {
+                    final Map<String, Object> localVars = (Map<String, Object>) context.getAttribute(COLLECTED_BOUND_VARS_MAP_VARNAME);
+                    if (localVars != null) {
+                        localVars.entrySet().forEach(e -> {
+                            // closures need to be cached for later use
+                            if (e.getValue() instanceof Closure)
+                                globalClosures.put(e.getKey(), (Closure) e.getValue());
 
-                        context.setAttribute(e.getKey(), e.getValue(), ScriptContext.ENGINE_SCOPE);
-                    });
+                            context.setAttribute(e.getKey(), e.getValue(), ScriptContext.ENGINE_SCOPE);
+                        });
 
-                    // get rid of the temporary collected vars
-                    context.removeAttribute(COLLECTED_BOUND_VARS_MAP_VARNAME, ScriptContext.ENGINE_SCOPE);
-                    localVars.clear();
+                        // get rid of the temporary collected vars
+                        context.removeAttribute(COLLECTED_BOUND_VARS_MAP_VARNAME, ScriptContext.ENGINE_SCOPE);
+                        localVars.clear();
+                    }
                 }
-            }
 
-            return o;
+                return o;
+            }
         } catch (Exception e) {
             throw new ScriptException(e);
         }
@@ -607,7 +617,7 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl implements
     }
 
     private synchronized void createClassLoader() {
-        final CompilerConfiguration conf = new CompilerConfiguration();
+        final CompilerConfiguration conf = new CompilerConfiguration(CompilerConfiguration.DEFAULT);
         conf.addCompilationCustomizers(this.importCustomizerProvider.create());
 
         customizerProviders.forEach(p -> conf.addCompilationCustomizers(p.create()));

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/762f6b22/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
index 19ced88..b18c020 100644
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/jsr223/GremlinGroovyScriptEngineTest.java
@@ -38,13 +38,15 @@ import javax.script.ScriptEngine;
 import javax.script.ScriptException;
 import javax.script.SimpleBindings;
 import java.awt.*;
+import java.io.StringWriter;
 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.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
@@ -71,6 +73,8 @@ import static org.junit.Assert.fail;
 public class GremlinGroovyScriptEngineTest {
     private static final Logger logger = LoggerFactory.getLogger(GremlinGroovyScriptEngineTest.class);
 
+    private static final Object[] EMPTY_ARGS = new Object[0];
+
     @Test
     public void shouldCompileScriptWithoutRequiringVariableBindings() throws Exception {
         // compile() should cache the script to avoid future compilation
@@ -426,4 +430,67 @@ public class GremlinGroovyScriptEngineTest {
             assertEquals(t.getValue0() * -1, t.getValue1().get(2).intValue());
         });
     }
+
+    @Test
+    public void shouldInvokeFunctionRedirectsOutputToContextWriter() throws Exception {
+        final GremlinGroovyScriptEngine engine = new GremlinGroovyScriptEngine();
+        StringWriter writer = new StringWriter();
+        engine.getContext().setWriter(writer);
+
+        final String code = "def myFunction() { print \"Hello World!\" }";
+        engine.eval(code);
+        engine.invokeFunction("myFunction", EMPTY_ARGS);
+        assertEquals("Hello World!", writer.toString());
+
+        writer = new StringWriter();
+        final StringWriter writer2 = new StringWriter();
+        engine.getContext().setWriter(writer2);
+        engine.invokeFunction("myFunction", EMPTY_ARGS);
+        assertEquals("", writer.toString());
+        assertEquals("Hello World!", writer2.toString());
+    }
+
+    @Test
+    public void testInvokeFunctionRedirectsOutputToContextOut() throws Exception {
+        final GremlinGroovyScriptEngine  engine = new GremlinGroovyScriptEngine();
+        StringWriter writer = new StringWriter();
+        final StringWriter unusedWriter = new StringWriter();
+        engine.getContext().setWriter(unusedWriter);
+        engine.put("out", writer);
+
+        final String code = "def myFunction() { print \"Hello World!\" }";
+        engine.eval(code);
+        engine.invokeFunction("myFunction", EMPTY_ARGS);
+        assertEquals("", unusedWriter.toString());
+        assertEquals("Hello World!", writer.toString());
+
+        writer = new StringWriter();
+        final StringWriter writer2 = new StringWriter();
+        engine.put("out", writer2);
+        engine.invokeFunction("myFunction", EMPTY_ARGS);
+        assertEquals("", unusedWriter.toString());
+        assertEquals("", writer.toString());
+        assertEquals("Hello World!", writer2.toString());
+    }
+
+    @Test
+    public void testEngineContextAccessibleToScript() throws Exception {
+        final GremlinGroovyScriptEngine  engine = new GremlinGroovyScriptEngine();
+        final ScriptContext engineContext = engine.getContext();
+        engine.put("theEngineContext", engineContext);
+        final String code = "[answer: theEngineContext.is(context)]";
+        assertThat(((Map) engine.eval(code)).get("answer"), is(true));
+    }
+
+    @Test
+    public void testContextBindingOverridesEngineContext() throws Exception {
+        final GremlinGroovyScriptEngine  engine = new GremlinGroovyScriptEngine();
+        final ScriptContext engineContext = engine.getContext();
+        final Map<String,Object> otherContext = new HashMap<>();
+        otherContext.put("foo", "bar");
+        engine.put("context", otherContext);
+        engine.put("theEngineContext", engineContext);
+        final String code = "[answer: context.is(theEngineContext) ? \"wrong\" : context.foo]";
+        assertEquals("bar", ((Map) engine.eval(code)).get("answer"));
+    }
 }
\ No newline at end of file


[5/6] tinkerpop git commit: TINKERPOP-1477 Made DependencyGrabberTest an integration test

Posted by dk...@apache.org.
TINKERPOP-1477 Made DependencyGrabberTest an integration test

This test has had a tendency to fail on travis and some other environments for some time now - probably better than as an integration test. CTR


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/0070d3db
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/0070d3db
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/0070d3db

Branch: refs/heads/TINKERPOP-1158
Commit: 0070d3dbd1154c8608ac360046f0650842a77c59
Parents: bdef1a4
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 28 17:41:42 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Sep 28 17:41:42 2016 -0400

----------------------------------------------------------------------
 .../util/DependencyGrabberIntegrateTest.java    | 102 +++++++++++++++++++
 .../groovy/util/DependencyGrabberTest.java      | 102 -------------------
 2 files changed, 102 insertions(+), 102 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0070d3db/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberIntegrateTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberIntegrateTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberIntegrateTest.java
new file mode 100644
index 0000000..7b3bba8
--- /dev/null
+++ b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberIntegrateTest.java
@@ -0,0 +1,102 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tinkerpop.gremlin.groovy.util;
+
+import groovy.lang.GroovyClassLoader;
+import java.io.File;
+import org.apache.commons.io.FileUtils;
+import org.apache.tinkerpop.gremlin.TestHelper;
+import org.apache.tinkerpop.gremlin.groovy.plugin.Artifact;
+import org.junit.AfterClass;
+import org.junit.Test;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * @author Jason Plurad (http://github.com/pluradj)
+ */
+public class DependencyGrabberIntegrateTest {
+    private static final GroovyClassLoader dummyClassLoader = new GroovyClassLoader();
+    private static final File extTestDir = new File(System.getProperty("user.dir"), TestHelper.makeTestDataDirectory(DependencyGrabberIntegrateTest.class));
+    private static final DependencyGrabber dg = new DependencyGrabber(dummyClassLoader, extTestDir.getAbsolutePath());
+
+    @AfterClass
+    public static void tearDown() {
+        FileUtils.deleteQuietly(extTestDir);
+    }
+
+    @Test
+    public void shouldInstallAndUninstallDependencies() {
+        final String pkg = "org.apache.tinkerpop";
+        final String name = "tinkergraph-gremlin";
+        final String ver = "3.0.1-incubating";
+        final Artifact a = new Artifact(pkg, name, ver);
+
+        // install the plugin
+        final File pluginDir = new File(extTestDir, name);
+        dg.copyDependenciesToPath(a);
+        assertTrue(pluginDir.exists());
+
+        // delete the plugin
+        dg.deleteDependenciesFromPath(a);
+        assertFalse(pluginDir.exists());
+    }
+
+    @Test(expected=IllegalStateException.class)
+    public void shouldThrowIllegalStateException() {
+        final String pkg = "org.apache.tinkerpop";
+        final String name = "gremlin-groovy";
+        final String ver = "3.0.1-incubating";
+        final Artifact a = new Artifact(pkg, name, ver);
+
+        // install the plugin for the first time
+        final File pluginDir = new File(extTestDir, name);
+        dg.copyDependenciesToPath(a);
+        assertTrue(pluginDir.exists());
+
+        // attempt to install plugin a second time
+        try {
+            dg.copyDependenciesToPath(a);
+        } catch (IllegalStateException ise) {
+            // validate that the plugin dir wasn't deleted by accident
+            assertTrue(pluginDir.exists());
+            // throw the IllegalStateException
+            throw ise;
+        }
+    }
+
+    @Test(expected=RuntimeException.class)
+    public void shouldThrowRuntimeException() {
+        final String pkg = "org.apache.tinkerpop";
+        final String name = "gremlin-bogus";
+        final String ver = "3.0.1-incubating";
+        final Artifact a = new Artifact(pkg, name, ver);
+
+        // attempt to install bogus plugin
+        try {
+            dg.copyDependenciesToPath(a);
+        } catch (RuntimeException re) {
+            // validate that the plugin dir was deleted
+            final File pluginDir = new File(extTestDir, name);
+            assertFalse(pluginDir.exists());
+            // throw the RuntimeException
+            throw re;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0070d3db/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberTest.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberTest.java b/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberTest.java
deleted file mode 100644
index f32b757..0000000
--- a/gremlin-groovy/src/test/java/org/apache/tinkerpop/gremlin/groovy/util/DependencyGrabberTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.tinkerpop.gremlin.groovy.util;
-
-import groovy.lang.GroovyClassLoader;
-import java.io.File;
-import org.apache.commons.io.FileUtils;
-import org.apache.tinkerpop.gremlin.TestHelper;
-import org.apache.tinkerpop.gremlin.groovy.plugin.Artifact;
-import org.junit.AfterClass;
-import org.junit.Test;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * @author Jason Plurad (http://github.com/pluradj)
- */
-public class DependencyGrabberTest {
-    private static final GroovyClassLoader dummyClassLoader = new GroovyClassLoader();
-    private static final File extTestDir = new File(System.getProperty("user.dir"), TestHelper.makeTestDataDirectory(DependencyGrabberTest.class));
-    private static final DependencyGrabber dg = new DependencyGrabber(dummyClassLoader, extTestDir.getAbsolutePath());
-
-    @AfterClass
-    public static void tearDown() {
-        FileUtils.deleteQuietly(extTestDir);
-    }
-
-    @Test
-    public void shouldInstallAndUninstallDependencies() {
-        final String pkg = "org.apache.tinkerpop";
-        final String name = "tinkergraph-gremlin";
-        final String ver = "3.0.1-incubating";
-        final Artifact a = new Artifact(pkg, name, ver);
-
-        // install the plugin
-        final File pluginDir = new File(extTestDir, name);
-        dg.copyDependenciesToPath(a);
-        assertTrue(pluginDir.exists());
-
-        // delete the plugin
-        dg.deleteDependenciesFromPath(a);
-        assertFalse(pluginDir.exists());
-    }
-
-    @Test(expected=IllegalStateException.class)
-    public void shouldThrowIllegalStateException() {
-        final String pkg = "org.apache.tinkerpop";
-        final String name = "gremlin-groovy";
-        final String ver = "3.0.1-incubating";
-        final Artifact a = new Artifact(pkg, name, ver);
-
-        // install the plugin for the first time
-        final File pluginDir = new File(extTestDir, name);
-        dg.copyDependenciesToPath(a);
-        assertTrue(pluginDir.exists());
-
-        // attempt to install plugin a second time
-        try {
-            dg.copyDependenciesToPath(a);
-        } catch (IllegalStateException ise) {
-            // validate that the plugin dir wasn't deleted by accident
-            assertTrue(pluginDir.exists());
-            // throw the IllegalStateException
-            throw ise;
-        }
-    }
-
-    @Test(expected=RuntimeException.class)
-    public void shouldThrowRuntimeException() {
-        final String pkg = "org.apache.tinkerpop";
-        final String name = "gremlin-bogus";
-        final String ver = "3.0.1-incubating";
-        final Artifact a = new Artifact(pkg, name, ver);
-
-        // attempt to install bogus plugin
-        try {
-            dg.copyDependenciesToPath(a);
-        } catch (RuntimeException re) {
-            // validate that the plugin dir was deleted
-            final File pluginDir = new File(extTestDir, name);
-            assertFalse(pluginDir.exists());
-            // throw the RuntimeException
-            throw re;
-        }
-    }
-}


[4/6] tinkerpop git commit: Merge branch 'pr-438' into tp31

Posted by dk...@apache.org.
Merge branch 'pr-438' into tp31


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/bdef1a4c
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/bdef1a4c
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/bdef1a4c

Branch: refs/heads/TINKERPOP-1158
Commit: bdef1a4c281c328bc25bc9168f442145360a7eb1
Parents: 762f6b2 3cbd371
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed Sep 28 12:53:46 2016 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed Sep 28 12:53:46 2016 -0400

----------------------------------------------------------------------
 docs/src/reference/gremlin-applications.asciidoc | 4 ++--
 gremlin-console/src/main/bin/gremlin.sh          | 4 ++--
 gremlin-driver/src/main/bin/config-eval.sh       | 4 ++--
 gremlin-driver/src/main/bin/profile-driver.sh    | 4 ++--
 gremlin-server/src/main/bin/gremlin-server.sh    | 4 ++--
 5 files changed, 10 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/bdef1a4c/docs/src/reference/gremlin-applications.asciidoc
----------------------------------------------------------------------


[6/6] tinkerpop git commit: Tweaked `gremlin.sh` so that it can be started from anywhere.

Posted by dk...@apache.org.
Tweaked `gremlin.sh` so that it can be started from anywhere.

Removed all shell scripts that just forwarded the command to another script and added symbolic links instead.


Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo
Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/9e0244ef
Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/9e0244ef
Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/9e0244ef

Branch: refs/heads/TINKERPOP-1158
Commit: 9e0244ef4275cf7d782949352a0185e4e5bda253
Parents: 0070d3d
Author: Daniel Kuppitz <da...@hotmail.com>
Authored: Wed Sep 28 22:13:56 2016 +0200
Committer: Daniel Kuppitz <da...@hotmail.com>
Committed: Thu Sep 29 11:44:16 2016 +0200

----------------------------------------------------------------------
 bin/gremlin.sh                          | 23 +---------------------
 docs/src/dev/developer/release.asciidoc |  4 +++-
 gremlin-console/bin/gremlin.sh          | 25 +-----------------------
 gremlin-console/src/main/bin/gremlin.sh | 29 ++++++++++++++++------------
 4 files changed, 22 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9e0244ef/bin/gremlin.sh
----------------------------------------------------------------------
diff --git a/bin/gremlin.sh b/bin/gremlin.sh
deleted file mode 100755
index 512f71f..0000000
--- a/bin/gremlin.sh
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/bash
-#
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-`dirname $0`/../gremlin-console/bin/gremlin.sh $@
diff --git a/bin/gremlin.sh b/bin/gremlin.sh
new file mode 120000
index 0000000..e99f01d
--- /dev/null
+++ b/bin/gremlin.sh
@@ -0,0 +1 @@
+../gremlin-console/bin/gremlin.sh
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9e0244ef/docs/src/dev/developer/release.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/dev/developer/release.asciidoc b/docs/src/dev/developer/release.asciidoc
index f9baa94..b066dd0 100644
--- a/docs/src/dev/developer/release.asciidoc
+++ b/docs/src/dev/developer/release.asciidoc
@@ -75,11 +75,13 @@ might be high.
 .. `mvn verify -DskipPerformanceTests=false`
 . `bin/publish-docs.sh <username>` - note that under a release candidate the documentation is published as SNAPSHOT
 . `mvn versions:set -DnewVersion=xx.yy.zz -DgenerateBackupPoms=false` to update the project files to reference a non-SNAPSHOT version
+. `pushd gremlin-console/bin; ln -fs ../target/apache-tinkerpop-gremlin-console-xx.yy.zz-standalone/bin/gremlin.sh gremlin.sh; popd`
 . `git diff` and review the updated files (expect all `pom.xml` files and this README)
 . `git commit -a -m "TinkerPop xx.yy.zz release"` and `git push`
 . `git tag -a -m "TinkerPop xx.yy.zz release" xx.yy.zz` and `git push --tags`
 . `mvn clean install`
 . `mvn versions:set -DnewVersion=xx.yy.zz-SNAPSHOT -DgenerateBackupPoms=false` to go back to SNAPSHOT
+. `pushd gremlin-console/bin; ln -fs ../target/apache-tinkerpop-gremlin-console-xx.yy.zz-SNAPSHOT-standalone/bin/gremlin.sh gremlin.sh; popd`
 . `git commit -a -m "Returned to xx.yy.zz-SNAPSHOT"` and `git push`
 . Announce the release candidate to `dev` mailing list and await feedback
 . Repeat as required or proceed to the next phase
@@ -267,4 +269,4 @@ The Central Maven repo has sync'd as well:
 https://repo1.maven.org/maven2/org/apache/tinkerpop/tinkerpop/xx.yy.zz/
 
 [include the release line logo image]
-----
\ No newline at end of file
+----

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9e0244ef/gremlin-console/bin/gremlin.sh
----------------------------------------------------------------------
diff --git a/gremlin-console/bin/gremlin.sh b/gremlin-console/bin/gremlin.sh
deleted file mode 100755
index d0d3240..0000000
--- a/gremlin-console/bin/gremlin.sh
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/bin/bash
-#
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-
-OPTS=$@
-set JAVA_OPTIONS="-Dtinkerpop.ext=/../target/apache-tinkerpop-gremlin-*-standalone/ext -Dlog4j.configuration=conf/log4j-console.properties -Dgremlin.log4j.level=$GREMLIN_LOG_LEVEL"
-`dirname $0`/../target/apache-tinkerpop-gremlin-*-standalone/bin/gremlin.sh $OPTS
diff --git a/gremlin-console/bin/gremlin.sh b/gremlin-console/bin/gremlin.sh
new file mode 120000
index 0000000..5825879
--- /dev/null
+++ b/gremlin-console/bin/gremlin.sh
@@ -0,0 +1 @@
+../target/apache-tinkerpop-gremlin-console-3.1.5-SNAPSHOT-standalone/bin/gremlin.sh
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/9e0244ef/gremlin-console/src/main/bin/gremlin.sh
----------------------------------------------------------------------
diff --git a/gremlin-console/src/main/bin/gremlin.sh b/gremlin-console/src/main/bin/gremlin.sh
index fe28773..dfcd325 100755
--- a/gremlin-console/src/main/bin/gremlin.sh
+++ b/gremlin-console/src/main/bin/gremlin.sh
@@ -23,7 +23,19 @@ set -e
 set -u
 
 DIR="$( cd -P "$( dirname "$0" )" && pwd )"
-SYSTEM_EXT_DIR="${DIR}/../ext"
+
+SOURCE="${BASH_SOURCE[0]}"
+while [ -h "$SOURCE" ]; do
+  DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
+  SOURCE="$(readlink "$SOURCE")"
+  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
+done
+
+WORKING_DIR="$( cd -P "${DIR}/.." && pwd )"
+SYSTEM_EXT_DIR="${WORKING_DIR}/ext"
+
+pushd ${WORKING_DIR} > /dev/null
+
 JAVA_OPTIONS=${JAVA_OPTIONS:-}
 
 if [ ! -z "${JAVA_OPTIONS}" ]; then
@@ -36,21 +48,12 @@ fi
 
 case `uname` in
   CYGWIN*)
-    CP="`dirname $0`"/../conf
-    CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /;/g')
+    CP="$CP";$( echo lib/*.jar . | sed 's/ /;/g')
     ;;
   *)
-    CP="`dirname $0`"/../conf
-    CP="$CP":$( echo `dirname $0`/../lib/*.jar . | sed 's/ /:/g')
+    CP="$CP":$( echo lib/*.jar . | sed 's/ /:/g')
 esac
 
-SOURCE="${BASH_SOURCE[0]}"
-while [ -h "$SOURCE" ]; do
-  DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
-  SOURCE="$(readlink "$SOURCE")"
-  [[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE"
-done
-
 CP=$CP:$( find -L "${SYSTEM_EXT_DIR}" "${USER_EXT_DIR:-${SYSTEM_EXT_DIR}}" -mindepth 1 -maxdepth 1 -type d | \
           sort -u | sed 's/$/\/plugin\/*/' | tr '\n' ':' )
 
@@ -111,3 +114,5 @@ fi
 
 # Start the JVM, execute the application, and return its exit code
 exec $JAVA $JAVA_OPTIONS $MAIN_CLASS "$@"
+
+popd > /dev/null