tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject tinkerpop git commit: TINKERPOP-1644 Made the "counter" in GremlinGroovyScriptEngine static
Date Wed, 08 Mar 2017 21:19:35 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1644 c583ba0c4 -> 6c2a28ead


TINKERPOP-1644 Made the "counter" in GremlinGroovyScriptEngine static

It seems that this field should be static and shared across all instances as the script name
seems to share space with other GroovyClassLoaders. Not sure what would happen in the case
of collision, but there doesn't seem to be much harm in ensuring better uniqueness. This counter
wasn't used for tracking the number of scripts actually processed or anything so it should
be ok to make this change without fear of breaking anything.


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

Branch: refs/heads/TINKERPOP-1644
Commit: 6c2a28eadf44daf5318bbfa65a05f4608f000811
Parents: c583ba0
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Wed Mar 8 16:17:40 2017 -0500
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Wed Mar 8 16:17:40 2017 -0500

----------------------------------------------------------------------
 .../groovy/jsr223/GremlinGroovyScriptEngine.java        | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/6c2a28ea/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 5168130..3bcb06c 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
@@ -196,7 +196,15 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
      */
     private final ManagedConcurrentValueMap<String, Closure> globalClosures = new ManagedConcurrentValueMap<>(ReferenceBundle.getHardBundle());
 
-    private final AtomicLong counter = new AtomicLong(0L);
+    /**
+     * Ensures unique script names across all instances.
+     */
+    private final static AtomicLong scriptNameCounter = new AtomicLong(0L);
+
+    /**
+     * A counter for the instance that tracks the number of warnings issued during script
compilations that exceeded
+     * the {@link #expectedCompilationTime}.
+     */
     private final AtomicLong longRunCompilationCount = new AtomicLong(0L);
 
     /**
@@ -799,7 +807,7 @@ public class GremlinGroovyScriptEngine extends GroovyScriptEngineImpl
     }
 
     private synchronized String generateScriptName() {
-        return SCRIPT + counter.incrementAndGet() + DOT_GROOVY;
+        return SCRIPT + scriptNameCounter.incrementAndGet() + DOT_GROOVY;
     }
 
     @SuppressWarnings("unchecked")


Mime
View raw message