[
https://issues.apache.org/jira/browse/TINKERPOP-1527?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15606185#comment-15606185
]
ASF GitHub Bot commented on TINKERPOP-1527:
-------------------------------------------
GitHub user okram opened a pull request:
https://github.com/apache/tinkerpop/pull/464
TINKERPOP-1527: Do not override registered strategies in
TraversalStrategies.GlobalCache
https://issues.apache.org/jira/browse/TINKERPOP-1527
`GraphComputer` strategy registration in `TraversalStrategy.GlobalCache`
has been a "uh..I think static{}-blocks load once and only once and when the
class is used?" ... This assumption lead to a few errant problems that have
been rectified and verified in this PR.
1.) `TraversalStrategies.GlobalCache` strategies can be manipulated without
fear of a new instance of the `Graph` or `GraphComputer` class over-writing
user manipulations. That is, a test case now proves that `static{}` loads once
and only once.
2.) `TraversalStrategies.GlobalCache.getStrategies()` is responsible for
ensuring that `static{}` has been called for the particular `Graph` or
`GraphComputer` class. A test case now proves that `Class.forName()` is
sufficient to accomplish this.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/apache/tinkerpop TINKERPOP-1527
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/tinkerpop/pull/464.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #464
----
commit f9bf0444e4bfe09dcea9b8dc05870ddaec4b6180
Author: Marko A. Rodriguez <[email protected]>
Date: 2016-10-25T19:02:29Z
TraversalStrategy.GlobalCache.getStrategies() is now the point where
static{} code blocks are loaded for Graph and GraphComputer classes. Added a
test case to TraversalStrategiesTset that demonstrates that the GlobalCache can
be manipulated without fear of static{} re-registering strategies. This is a
much much safer model and, moreover, proved correct via testing.
commit b0bedf6b441edddbfd2e005641fee0a044b3b552
Author: Marko A. Rodriguez <[email protected]>
Date: 2016-10-25T19:07:01Z
added authorship to TraversalStrategies java file.
----
> Do not override registered strategies in TraversalStrategies.GlobalCache
> ------------------------------------------------------------------------
>
> Key: TINKERPOP-1527
> URL: https://issues.apache.org/jira/browse/TINKERPOP-1527
> Project: TinkerPop
> Issue Type: Improvement
> Components: process
> Affects Versions: 3.2.3
> Reporter: Marko A. Rodriguez
> Assignee: Marko A. Rodriguez
>
> This may be a non-issue (need to check), but we currently do this in every
> {{Graph}} (and {{GraphComputer}}) class.
> {code}
> static {
> TraversalStrategies.GlobalCache.registerStrategies(TinkerGraph.class,
> TraversalStrategies.GlobalCache.getStrategies(Graph.class).clone().addStrategies(TinkerGraphStepStrategy.instance()));
> }
> {code}
> If this static code is loaded every time a {{Graph}} instance is created,
> then manually tweaked strategy registrations get overwritten. If this is the
> case, then we should do:
> {code}
> static {
>
> TraversalStrategies.GlobalCache.registerStrategiesIfNotPresent(TinkerGraph.class,TraversalStrategies.GlobalCache.getStrategies(Graph.class).clone().addStrategies(TinkerGraphStepStrategy.instance()));
> }
> {code}
> That is, add a {{registerIfNotPresent()}} method.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)