From commits-return-28589-archive-asf-public=cust-asf.ponee.io@tinkerpop.apache.org Thu Apr 26 02:03:01 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 69644180804 for ; Thu, 26 Apr 2018 02:02:55 +0200 (CEST) Received: (qmail 62240 invoked by uid 500); 26 Apr 2018 00:02:54 -0000 Mailing-List: contact commits-help@tinkerpop.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@tinkerpop.apache.org Delivered-To: mailing list commits@tinkerpop.apache.org Received: (qmail 61749 invoked by uid 99); 26 Apr 2018 00:02:54 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Apr 2018 00:02:54 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id B40F9F6539; Thu, 26 Apr 2018 00:02:53 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dkuppitz@apache.org To: commits@tinkerpop.apache.org Date: Thu, 26 Apr 2018 00:03:38 -0000 Message-Id: <9624e6e3109b4f76904f929a52cb6dbc@git.apache.org> In-Reply-To: <7869f23d47a740e2a7531eb2b872a97a@git.apache.org> References: <7869f23d47a740e2a7531eb2b872a97a@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [46/50] [abbrv] tinkerpop git commit: Reverted change from 1d9e6dc6d30c5c7d56e4007527365793eb1f223e Reverted change from 1d9e6dc6d30c5c7d56e4007527365793eb1f223e Not sure why, but the above referenced change seemed to hang various integration tests. CTR Project: http://git-wip-us.apache.org/repos/asf/tinkerpop/repo Commit: http://git-wip-us.apache.org/repos/asf/tinkerpop/commit/789e5752 Tree: http://git-wip-us.apache.org/repos/asf/tinkerpop/tree/789e5752 Diff: http://git-wip-us.apache.org/repos/asf/tinkerpop/diff/789e5752 Branch: refs/heads/TINKERPOP-1447 Commit: 789e5752d8f6f781272a7c56f0d2b491849d4ca9 Parents: 6096a4c Author: Stephen Mallette Authored: Wed Apr 25 18:38:53 2018 -0400 Committer: Stephen Mallette Committed: Wed Apr 25 18:38:53 2018 -0400 ---------------------------------------------------------------------- .../process/traversal/TraversalStrategies.java | 43 +++++++++----------- 1 file changed, 20 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/789e5752/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java ---------------------------------------------------------------------- diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java index 37cd1a6..091687a 100644 --- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java +++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/TraversalStrategies.java @@ -203,7 +203,7 @@ public interface TraversalStrategies extends Serializable, Cloneable { * Keeps track of {@link GraphComputer} and/or {@link Graph} classes that have been initialized to the * classloader so that they do not have to be reflected again. */ - private static Map LOADED = new ConcurrentHashMap<>(); + private static Set LOADED = ConcurrentHashMap.newKeySet(); private static final Map, TraversalStrategies> GRAPH_CACHE = new HashMap<>(); private static final Map, TraversalStrategies> GRAPH_COMPUTER_CACHE = new HashMap<>(); @@ -249,28 +249,27 @@ public interface TraversalStrategies extends Serializable, Cloneable { } public static TraversalStrategies getStrategies(final Class graphOrGraphComputerClass) { - // be sure to load the class so that its static{} traversal strategy registration component is loaded. - // this is more important for GraphComputer classes as they are typically not instantiated prior to - // strategy usage like Graph classes. - LOADED.computeIfAbsent(graphOrGraphComputerClass, unused -> { - final String graphComputerClassName = null != graphOrGraphComputerClass.getDeclaringClass() ? - graphOrGraphComputerClass.getCanonicalName().replace("." + graphOrGraphComputerClass.getSimpleName(), "$" + graphOrGraphComputerClass.getSimpleName()) : - graphOrGraphComputerClass.getCanonicalName(); - - try { + try { + // be sure to load the class so that its static{} traversal strategy registration component is loaded. + // this is more important for GraphComputer classes as they are typically not instantiated prior to + // strategy usage like Graph classes. + if (!LOADED.contains(graphOrGraphComputerClass)) { + final String graphComputerClassName = null != graphOrGraphComputerClass.getDeclaringClass() ? + graphOrGraphComputerClass.getCanonicalName().replace("." + graphOrGraphComputerClass.getSimpleName(), "$" + graphOrGraphComputerClass.getSimpleName()) : + graphOrGraphComputerClass.getCanonicalName(); Class.forName(graphComputerClassName); - } catch (ClassNotFoundException e) { - throw new IllegalStateException(e.getMessage(), e); + + // keep track of stuff we already loaded once - stuff in this if/statement isn't cheap and this + // method gets called a lot, basically every time a new traversal gets spun up (that includes + // child traversals. perhaps it is possible to just check the cache keys for this information, but + // it's not clear if this method will be called with something not in the cache and if it is and + // it results in error, then we'd probably not want to deal with this block again anyway + LOADED.add(graphOrGraphComputerClass); } + } catch (final ClassNotFoundException e) { + throw new IllegalStateException(e.getMessage(), e); + } - // keep track of stuff we already loaded once - stuff in this if/statement isn't cheap and this - // method gets called a lot, basically every time a new traversal gets spun up (that includes - // child traversals. perhaps it is possible to just check the cache keys for this information, but - // it's not clear if this method will be called with something not in the cache and if it is and - // it results in error, then we'd probably not want to deal with this block again anyway - return true; - }); - if (GRAPH_CACHE.containsKey(graphOrGraphComputerClass)) { return GRAPH_CACHE.get(graphOrGraphComputerClass); } else if (Graph.class.isAssignableFrom(graphOrGraphComputerClass)) { @@ -284,6 +283,4 @@ public interface TraversalStrategies extends Serializable, Cloneable { } } } - - -} +} \ No newline at end of file