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 2015/05/13 14:48:41 UTC

incubator-tinkerpop git commit: Sugar is applied once for the life of the jvm.

Repository: incubator-tinkerpop
Updated Branches:
  refs/heads/sugar [created] aea991335


Sugar is applied once for the life of the jvm.


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

Branch: refs/heads/sugar
Commit: aea99133507c5c7bb95b260820e8a0c221c288c8
Parents: 09826d5
Author: Stephen Mallette <sp...@genoprime.com>
Authored: Wed May 13 08:48:08 2015 -0400
Committer: Stephen Mallette <sp...@genoprime.com>
Committed: Wed May 13 08:48:08 2015 -0400

----------------------------------------------------------------------
 .../groovy/loaders/SugarLoaderTest.groovy       |  28 ++--
 .../groovy/GroovyEnvironmentIntegrateSuite.java |  31 +----
 .../GroovyEnvironmentPerformanceSuite.java      |  31 +----
 .../gremlin/groovy/GroovyEnvironmentSuite.java  |  31 +----
 .../process/GroovyProcessComputerSuite.java     |  27 +---
 .../process/GroovyProcessStandardSuite.java     |  26 +---
 .../gremlin/groovy/loaders/GremlinLoader.groovy |   9 +-
 .../gremlin/groovy/loaders/ObjectLoader.groovy  |   7 +-
 .../gremlin/groovy/loaders/StepLoader.groovy    |   7 +-
 .../gremlin/groovy/loaders/SugarLoader.groovy   | 132 ++++++++++---------
 10 files changed, 117 insertions(+), 212 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/aea99133/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
index 15e4c6d..89d5cc9 100644
--- a/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
+++ b/gremlin-groovy-test/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoaderTest.groovy
@@ -4,7 +4,7 @@
  * 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
+ * "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
@@ -21,7 +21,6 @@ package org.apache.tinkerpop.gremlin.groovy.loaders
 import org.apache.tinkerpop.gremlin.AbstractGremlinTest
 import org.apache.tinkerpop.gremlin.LoadGraphWith
 import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper
-import org.apache.tinkerpop.gremlin.structure.Graph
 import org.apache.tinkerpop.gremlin.structure.Vertex
 import org.junit.Test
 
@@ -32,19 +31,18 @@ import static org.junit.Assert.*
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 class SugarLoaderTest extends AbstractGremlinTest {
-
-    @Override
-    protected void afterLoadGraphWith(final Graph g) throws Exception {
-        SugarTestHelper.clearRegistry(graphProvider)
+    static {
+        SugarLoader.load()
     }
 
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
+    @org.junit.Ignore("This test no longer passes as sugar loads once for the jvm and can't be disabled")
     public void shouldNotAllowSugar() {
         SugarTestHelper.clearRegistry(graphProvider)
         try {
             g.V
-            fail("Without sugar loaded, the traversal should fail");
+            fail("Without sugar loaded, the traversal should fail")
         } catch (MissingPropertyException e) {
 
         } catch (Exception e) {
@@ -53,7 +51,7 @@ class SugarLoaderTest extends AbstractGremlinTest {
 
         try {
             g.V().out
-            fail("Without sugar loaded, the traversal should fail");
+            fail("Without sugar loaded, the traversal should fail")
         } catch (MissingPropertyException e) {
 
         } catch (Exception e) {
@@ -62,7 +60,7 @@ class SugarLoaderTest extends AbstractGremlinTest {
 
         try {
             g.V().out().name
-            fail("Without sugar loaded, the traversal should fail");
+            fail("Without sugar loaded, the traversal should fail")
         } catch (MissingPropertyException e) {
 
         } catch (Exception e) {
@@ -73,26 +71,24 @@ class SugarLoaderTest extends AbstractGremlinTest {
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
     public void shouldAllowSugar() {
-        SugarLoader.load()
         assertEquals(6, g.V.count.next())
         assertEquals(6, g.V.out.count.next())
         assertEquals(6, g.V.out.name.count.next())
-        assertEquals(2, g.V(1).out.out.name.count.next());
+        assertEquals(2, g.V(1).out.out.name.count.next())
         g.V(1).next().name = 'okram'
-        assertEquals('okram', g.V(1).next().name);
+        assertEquals('okram', g.V(1).next().name)
         g.V(1).next()['name'] = 'marko a. rodriguez'
-        assertEquals(["okram", "marko a. rodriguez"] as Set, g.V(1).values('name').toSet());
+        assertEquals(["okram", "marko a. rodriguez"] as Set, g.V(1).values('name').toSet())
     }
 
     @Test
     @LoadGraphWith(LoadGraphWith.GraphData.MODERN)
     public void shouldUseTraverserCategoryCorrectly() {
-        SugarLoader.load()
         g.V.as('a').out.as('x').name.as('b').back('x').has('age').map { [it.a, it.b, it.age] }.forEach {
-            // println it;
+            // println it
             assertTrue(it[0] instanceof Vertex)
             assertTrue(it[1] instanceof String)
             assertTrue(it[2] instanceof Integer)
-        };
+        }
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/aea99133/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentIntegrateSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentIntegrateSuite.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentIntegrateSuite.java
index db4d0e5..c3235e2 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentIntegrateSuite.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentIntegrateSuite.java
@@ -19,22 +19,14 @@
 package org.apache.tinkerpop.gremlin.groovy;
 
 import org.apache.tinkerpop.gremlin.AbstractGremlinSuite;
-import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
-import org.apache.tinkerpop.gremlin.GraphManager;
 import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineIntegrateTest;
 import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader;
-import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.StructureStandardSuite;
 import org.junit.runners.model.InitializationError;
 import org.junit.runners.model.RunnerBuilder;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
 /**
  * The {@code GroovyEnvironmentIntegrateSuite} is a JUnit test runner that executes the Gremlin Test Suite over a
  * {@link Graph} implementation.  This test suite covers ensures that a vendor implementation is compliant with
@@ -48,6 +40,9 @@ import java.util.stream.Stream;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class GroovyEnvironmentIntegrateSuite extends AbstractGremlinSuite {
+    static {
+        SugarLoader.load();
+    }
 
     /**
      * This list of tests in the suite that will be executed.  Gremlin developers should add to this list
@@ -60,24 +55,4 @@ public class GroovyEnvironmentIntegrateSuite extends AbstractGremlinSuite {
     public GroovyEnvironmentIntegrateSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
         super(klass, builder, allTests, null, false, TraversalEngine.Type.STANDARD);
     }
-
-    @Override
-    public boolean beforeTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
-        unloadSugar();
-        SugarLoader.load();
-        return true;
-    }
-
-    @Override
-    public void afterTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
-        unloadSugar();
-    }
-
-    private void unloadSugar() {
-        try {
-            SugarTestHelper.clearRegistry(GraphManager.getGraphProvider());
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/aea99133/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java
index 1108185..ef057a4 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentPerformanceSuite.java
@@ -19,23 +19,15 @@
 package org.apache.tinkerpop.gremlin.groovy;
 
 import org.apache.tinkerpop.gremlin.AbstractGremlinSuite;
-import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
-import org.apache.tinkerpop.gremlin.GraphManager;
 import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutorPerformanceTest;
 import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader;
 import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoaderPerformanceTest;
-import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.StructureStandardSuite;
 import org.junit.runners.model.InitializationError;
 import org.junit.runners.model.RunnerBuilder;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
 /**
  * The {@code GroovyEnvironmentPerformanceSuite} is a JUnit test runner that executes the Gremlin Test Suite over a
  * {@link Graph} implementation.  This test suite covers ensures that a vendor implementation is compliant with
@@ -50,6 +42,9 @@ import java.util.stream.Stream;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class GroovyEnvironmentPerformanceSuite extends AbstractGremlinSuite {
+    static {
+        SugarLoader.load();
+    }
 
     /**
      * This list of tests in the suite that will be executed.  Gremlin developers should add to this list
@@ -63,24 +58,4 @@ public class GroovyEnvironmentPerformanceSuite extends AbstractGremlinSuite {
     public GroovyEnvironmentPerformanceSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
         super(klass, builder, allTests, null, false, TraversalEngine.Type.STANDARD);
     }
-
-    @Override
-    public boolean beforeTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
-        unloadSugar();
-        SugarLoader.load();
-        return true;
-    }
-
-    @Override
-    public void afterTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
-        unloadSugar();
-    }
-
-    private void unloadSugar() {
-        try {
-            SugarTestHelper.clearRegistry(GraphManager.getGraphProvider());
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/aea99133/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java
index 4a775f4..f1a6d36 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/groovy/GroovyEnvironmentSuite.java
@@ -19,24 +19,16 @@
 package org.apache.tinkerpop.gremlin.groovy;
 
 import org.apache.tinkerpop.gremlin.AbstractGremlinSuite;
-import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
-import org.apache.tinkerpop.gremlin.GraphManager;
 import org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutorOverGraphTest;
 import org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngineOverGraphTest;
 import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader;
 import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoaderTest;
-import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper;
 import org.apache.tinkerpop.gremlin.process.traversal.TraversalEngine;
 import org.apache.tinkerpop.gremlin.structure.Graph;
 import org.apache.tinkerpop.gremlin.structure.StructureStandardSuite;
 import org.junit.runners.model.InitializationError;
 import org.junit.runners.model.RunnerBuilder;
 
-import java.util.Arrays;
-import java.util.List;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
 /**
  * The {@code GroovyEnvironmentSuite} is a JUnit test runner that executes the Gremlin Test Suite over a
  * {@link Graph} implementation.  This test suite covers ensures that a vendor implementation is compliant with
@@ -48,6 +40,9 @@ import java.util.stream.Stream;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class GroovyEnvironmentSuite extends AbstractGremlinSuite {
+    static {
+        SugarLoader.load();
+    }
 
     /**
      * This list of tests in the suite that will be executed.  Gremlin developers should add to this list
@@ -62,24 +57,4 @@ public class GroovyEnvironmentSuite extends AbstractGremlinSuite {
     public GroovyEnvironmentSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
         super(klass, builder, allTests, null, false, TraversalEngine.Type.STANDARD);
     }
-
-    @Override
-    public boolean beforeTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
-        unloadSugar();
-        SugarLoader.load();
-        return true;
-    }
-
-    @Override
-    public void afterTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
-        unloadSugar();
-    }
-
-    private void unloadSugar() {
-        try {
-            SugarTestHelper.clearRegistry(GraphManager.getGraphProvider());
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/aea99133/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessComputerSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessComputerSuite.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessComputerSuite.java
index 5e3df10..7cacdda 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessComputerSuite.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessComputerSuite.java
@@ -18,10 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.process;
 
-import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
-import org.apache.tinkerpop.gremlin.GraphManager;
 import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader;
-import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper;
 import org.apache.tinkerpop.gremlin.process.computer.GraphComputer;
 import org.apache.tinkerpop.gremlin.process.computer.ranking.PageRankVertexProgramTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.*;
@@ -46,6 +43,10 @@ import org.junit.runners.model.RunnerBuilder;
  */
 public class GroovyProcessComputerSuite extends ProcessComputerSuite {
 
+    static {
+        SugarLoader.load();
+    }
+
     /**
      * This list of tests in the suite that will be executed.  Gremlin developers should add to this list
      * as needed to enforce tests upon implementations.
@@ -113,24 +114,4 @@ public class GroovyProcessComputerSuite extends ProcessComputerSuite {
     public GroovyProcessComputerSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
         super(klass, builder, allTests);
     }
-
-    @Override
-    public boolean beforeTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
-        unloadSugar();
-        SugarLoader.load();
-        return true;
-    }
-
-    @Override
-    public void afterTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
-        unloadSugar();
-    }
-
-    private void unloadSugar() {
-        try {
-            SugarTestHelper.clearRegistry(GraphManager.getGraphProvider());
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/aea99133/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessStandardSuite.java
----------------------------------------------------------------------
diff --git a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessStandardSuite.java b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessStandardSuite.java
index b67d6e1..98f073b 100644
--- a/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessStandardSuite.java
+++ b/gremlin-groovy-test/src/main/java/org/apache/tinkerpop/gremlin/process/GroovyProcessStandardSuite.java
@@ -18,10 +18,7 @@
  */
 package org.apache.tinkerpop.gremlin.process;
 
-import org.apache.tinkerpop.gremlin.AbstractGremlinTest;
-import org.apache.tinkerpop.gremlin.GraphManager;
 import org.apache.tinkerpop.gremlin.groovy.loaders.SugarLoader;
-import org.apache.tinkerpop.gremlin.groovy.util.SugarTestHelper;
 import org.apache.tinkerpop.gremlin.process.traversal.CoreTraversalTest;
 import org.apache.tinkerpop.gremlin.process.traversal.GroovyTraversalSideEffectsTest;
 import org.apache.tinkerpop.gremlin.process.traversal.step.branch.GroovyBranchTest;
@@ -87,6 +84,9 @@ import org.junit.runners.model.RunnerBuilder;
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 public class GroovyProcessStandardSuite extends ProcessStandardSuite {
+    static {
+        SugarLoader.load();
+    }
 
     /**
      * This list of tests in the suite that will be executed.  Gremlin developers should add to this list
@@ -156,24 +156,4 @@ public class GroovyProcessStandardSuite extends ProcessStandardSuite {
     public GroovyProcessStandardSuite(final Class<?> klass, final RunnerBuilder builder) throws InitializationError {
         super(klass, builder, allTests);
     }
-
-    @Override
-    public boolean beforeTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
-        unloadSugar();
-        SugarLoader.load();
-        return true;
-    }
-
-    @Override
-    public void afterTestExecution(final Class<? extends AbstractGremlinTest> testClass) {
-        unloadSugar();
-    }
-
-    private void unloadSugar() {
-        try {
-            SugarTestHelper.clearRegistry(GraphManager.getGraphProvider());
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/aea99133/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/GremlinLoader.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/GremlinLoader.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/GremlinLoader.groovy
index 758768e..5f70027 100644
--- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/GremlinLoader.groovy
+++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/GremlinLoader.groovy
@@ -17,14 +17,21 @@
  * under the License.
  */
 package org.apache.tinkerpop.gremlin.groovy.loaders
+
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
  * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 class GremlinLoader {
 
-    public static void load() {
+    private static volatile boolean loaded = false
+
+    public synchronized static void load() {
+        if (loaded) return
+
         ObjectLoader.load()
         StepLoader.load()
+
+        loaded = true
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/aea99133/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/ObjectLoader.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/ObjectLoader.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/ObjectLoader.groovy
index b7f0ec2..3c19702 100644
--- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/ObjectLoader.groovy
+++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/ObjectLoader.groovy
@@ -23,7 +23,10 @@ package org.apache.tinkerpop.gremlin.groovy.loaders
 
 class ObjectLoader {
 
-    public static void load() {
+    private static volatile boolean loaded = false
+
+    public synchronized static void load() {
+        if (loaded) return
 
         Map.metaClass.getAt = { final IntRange range ->
             final int size = delegate.size();
@@ -43,5 +46,7 @@ class ObjectLoader {
             }
             return tempMap;
         }
+
+        loaded = true
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/aea99133/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
index ecba410..ee5a596 100644
--- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
+++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/StepLoader.groovy
@@ -30,7 +30,10 @@ import org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSo
  */
 class StepLoader {
 
-    public static void load() {
+    private static volatile boolean loaded = false
+
+    public synchronized static void load() {
+        if (loaded) return
 
         GraphTraversal.metaClass.by = { final Closure closure ->
             return ((GraphTraversal) delegate).by(1 == closure.getMaximumNumberOfParameters() ? new GFunction(closure) : new GComparator(closure));
@@ -52,5 +55,7 @@ class StepLoader {
             final Closure closure, final Closure operator ->
                 return ((GraphTraversalSource.GraphTraversalSourceStub) delegate).withSack(new GSupplier(closure), new GUnaryOperator(operator));
         }
+
+        loaded = true
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tinkerpop/blob/aea99133/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoader.groovy
----------------------------------------------------------------------
diff --git a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoader.groovy b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoader.groovy
index 21a2bcd..e07bec1 100644
--- a/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoader.groovy
+++ b/gremlin-groovy/src/main/groovy/org/apache/tinkerpop/gremlin/groovy/loaders/SugarLoader.groovy
@@ -4,7 +4,7 @@
  * 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
+ * "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
@@ -29,163 +29,169 @@ import org.apache.tinkerpop.gremlin.structure.util.StringFactory
 
 /**
  * @author Marko A. Rodriguez (http://markorodriguez.com)
+ * @author Stephen Mallette (http://stephen.genoprime.com)
  */
 class SugarLoader {
+    
+    private static volatile boolean loaded = false
 
-    private static final String NAME = "name";
-    private static final String FROM = "from";
-    private static final String SELECT = "select";
+    private static final String NAME = "name"
+    private static final String FROM = "from"
+    private static final String SELECT = "select"
 
-    public static void load() {
-
-        GremlinLoader.load();
+    public static synchronized void load() {
+        if (loaded) return
+        
+        GremlinLoader.load()
 
         Traverser.metaClass.getProperty = { final String key ->
-            TraverserCategory.get((Traverser) delegate, key);
+            TraverserCategory.get((Traverser) delegate, key)
         }
         // g.V.map{it.label()}
         Traverser.metaClass.methodMissing = { final String name, final def args ->
-            ((Traverser) delegate).get()."$name"(*args);
+            ((Traverser) delegate).get()."$name"(*args)
         }
         // g.V.age
         GraphTraversal.metaClass.methodMissing = { final String name, final def args ->
             if (name.toLowerCase().equals(FROM))
-                return ((GraphTraversal.Admin) args[0]).addStep(((GraphTraversal.Admin) delegate).getSteps()[0]);
+                return ((GraphTraversal.Admin) args[0]).addStep(((GraphTraversal.Admin) delegate).getSteps()[0])
             else
-                return ((GraphTraversal) delegate).values(name);
+                return ((GraphTraversal) delegate).values(name)
         }
 
         GraphTraversalSource.metaClass.getProperty = { final String key ->
-            GraphTraversalSourceCategory.get((GraphTraversalSource) delegate, key);
+            GraphTraversalSourceCategory.get((GraphTraversalSource) delegate, key)
         }
 
         GraphTraversalSource.GraphTraversalSourceStub.metaClass.getProperty = { final String key ->
-            GraphTraversalSourceStubCategory.get((GraphTraversalSource.GraphTraversalSourceStub) delegate, key);
+            GraphTraversalSourceStubCategory.get((GraphTraversalSource.GraphTraversalSourceStub) delegate, key)
         }
 
         // __.age and __.out
         __.metaClass.static.propertyMissing = { final String name ->
-            return null != __.metaClass.getMetaMethod(name) ? __."$name"() : __.values(name);
+            return null != __.metaClass.getMetaMethod(name) ? __."$name"() : __.values(name)
         }
         // __.name
         __.metaClass.static.getName = {
-            return __.values(NAME);
+            return __.values(NAME)
         }
         // out and age
         /*Object.metaClass.propertyMissing = { final String name ->
             if (name.equals(NAME))
-                return __.values(NAME);
+                return __.values(NAME)
             else
-                return __."$name";
+                return __."$name"
         }*/
 
         // select x,y from ...
         Object.metaClass.methodMissing = { final String name, final def args ->
             if (name.toLowerCase().equals(SELECT)) return __.select(*args)
-            throw new MissingMethodException(name, delegate.getClass(), args);
+            throw new MissingMethodException(name, delegate.getClass(), args)
         }
 
-        Traverser.metaClass.mixin(TraverserCategory.class);
-        GraphTraversalSource.metaClass.mixin(GraphTraversalSourceCategory.class);
-        GraphTraversalSource.GraphTraversalSourceStub.metaClass.mixin(GraphTraversalSourceStubCategory.class);
-        GraphTraversal.metaClass.mixin(GraphTraversalCategory.class);
-        Vertex.metaClass.mixin(VertexCategory.class);
-        Edge.metaClass.mixin(ElementCategory.class);
-        VertexProperty.metaClass.mixin(ElementCategory.class);
+        Traverser.metaClass.mixin(TraverserCategory.class)
+        GraphTraversalSource.metaClass.mixin(GraphTraversalSourceCategory.class)
+        GraphTraversalSource.GraphTraversalSourceStub.metaClass.mixin(GraphTraversalSourceStubCategory.class)
+        GraphTraversal.metaClass.mixin(GraphTraversalCategory.class)
+        Vertex.metaClass.mixin(VertexCategory.class)
+        Edge.metaClass.mixin(ElementCategory.class)
+        VertexProperty.metaClass.mixin(ElementCategory.class)
+
+        loaded = true
     }
 
     public static class TraverserCategory {
         public static final get(final Traverser traverser, final String key) {
-            return traverser.get()."$key";
+            return traverser.get()."$key"
         }
 
         public String toString() {
-            return this.metaClass.owner.get().toString();
+            return this.metaClass.owner.get().toString()
         }
     }
 
     public static class ElementCategory {
         public static final Object get(final Element element, final String key) {
-            // TODO: Weird:::: return element.property(key).orElseGet{vertex."$key"()};
-            final Property property = element.property(key);
+            // TODO: Weird:::: return element.property(key).orElseGet{vertex."$key"()}
+            final Property property = element.property(key)
             if (property.isPresent())
-                return property.value();
+                return property.value()
             else
-                return element."$key"();
+                return element."$key"()
         }
 
         public static final set(final Element element, final String key, final Object value) {
-            element.property(key, value);
+            element.property(key, value)
         }
 
         public String toString() {
             if (this.metaClass.owner instanceof Vertex)
-                return StringFactory.vertexString(this.metaClass.owner);
+                return StringFactory.vertexString(this.metaClass.owner)
             else if (this.metaClass.owner instanceof Edge)
-                return StringFactory.edgeString(this.metaClass.owner);
+                return StringFactory.edgeString(this.metaClass.owner)
             else
-                return StringFactory.propertyString(this.metaClass.owner);
+                return StringFactory.propertyString(this.metaClass.owner)
         }
     }
 
     public static class VertexCategory {
         public static final Object get(final Vertex vertex, final String key) {
-            // TODO: Weird:::: return vertex.property(key).orElseGet{vertex."$key"()};
-            final Property property = vertex.property(key);
+            // TODO: Weird:::: return vertex.property(key).orElseGet{vertex."$key"()}
+            final Property property = vertex.property(key)
             if (property.isPresent())
-                return property.value();
+                return property.value()
             else
-                return vertex."$key"();
+                return vertex."$key"()
         }
 
         public static final set(final Vertex vertex, final String key, final Object value) {
-            vertex.property(VertexProperty.Cardinality.single, key, value);
+            vertex.property(VertexProperty.Cardinality.single, key, value)
         }
 
         public static final putAt(final Vertex vertex, final String key, final Object value) {
-            vertex.property(VertexProperty.Cardinality.list, key, value);
+            vertex.property(VertexProperty.Cardinality.list, key, value)
         }
 
         public String toString() {
-            return StringFactory.vertexString(this.metaClass.owner);
+            return StringFactory.vertexString(this.metaClass.owner)
         }
     }
 
     public static class GraphTraversalSourceCategory {
 
-        private static final String V = "V";
-        private static final String E = "E";
+        private static final String V = "V"
+        private static final String E = "E"
 
         public static final get(final GraphTraversalSource graphTraversalSource, final String key) {
             if (key.equals(V))
-                return graphTraversalSource.V();
+                return graphTraversalSource.V()
             else if (key.equals(E))
-                return graphTraversalSource.E();
+                return graphTraversalSource.E()
             else
-                throw new UnsupportedOperationException("The provided key does not reference a known method: " + key);
+                throw new UnsupportedOperationException("The provided key does not reference a known method: " + key)
         }
 
         /*public String toString() {
-            return StringFactory.graphString(this.metaClass.owner, "");
+            return StringFactory.graphString(this.metaClass.owner, "")
         }*/
     }
 
     public static class GraphTraversalSourceStubCategory {
 
-        private static final String V = "V";
-        private static final String E = "E";
+        private static final String V = "V"
+        private static final String E = "E"
 
         public static final get(final GraphTraversalSource.GraphTraversalSourceStub graphTraversalSourceStub, final String key) {
             if (key.equals(V))
-                return graphTraversalSourceStub.V();
+                return graphTraversalSourceStub.V()
             else if (key.equals(E))
-                return graphTraversalSourceStub.E();
+                return graphTraversalSourceStub.E()
             else
-                throw new UnsupportedOperationException("The provided key does not reference a known method: " + key);
+                throw new UnsupportedOperationException("The provided key does not reference a known method: " + key)
         }
 
         /*public String toString() {
-            return StringFactory.graphString(this.metaClass.owner, "");
+            return StringFactory.graphString(this.metaClass.owner, "")
         }*/
     }
 
@@ -196,31 +202,31 @@ class SugarLoader {
         }
 
         public static final getAt(final GraphTraversal graphTraversal, final Integer index) {
-            graphTraversal.range(index, index + 1);
+            graphTraversal.range(index, index + 1)
         }
 
         public static final getAt(final GraphTraversal graphTraversal, final Range range) {
-            graphTraversal.range(range.getFrom() as Integer, range.getTo() as Integer);
+            graphTraversal.range(range.getFrom() as Integer, range.getTo() as Integer)
         }
 
         public static final or(final GraphTraversal.Admin leftTraversal, final Traversal.Admin rightTraversal) {
-            leftTraversal.or();
+            leftTraversal.or()
             rightTraversal.getSteps().forEach { step ->
-                leftTraversal.addStep(step);
+                leftTraversal.addStep(step)
             }
-            return leftTraversal;
+            return leftTraversal
         }
 
         public static final and(final GraphTraversal.Admin leftTraversal, final Traversal.Admin rightTraversal) {
-            leftTraversal.and();
+            leftTraversal.and()
             rightTraversal.getSteps().forEach { step ->
-                leftTraversal.addStep(step);
+                leftTraversal.addStep(step)
             }
-            return leftTraversal;
+            return leftTraversal
         }
 
         public String toString() {
-            return TraversalHelper.makeTraversalString(this.metaClass.owner);
+            return TraversalHelper.makeTraversalString(this.metaClass.owner)
         }
     }
 }
\ No newline at end of file