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-1798 Fix signature of MutationListener.vertexPropertyChanged()
Date Fri, 20 Oct 2017 16:22:27 GMT
Repository: tinkerpop
Updated Branches:
  refs/heads/TINKERPOP-1798 [created] 0a06a8612


TINKERPOP-1798 Fix signature of MutationListener.vertexPropertyChanged()

This method was referencing a Property when it should have been referencing a VertexProperty.
Implemented by way of deprecation of the old method so that this ends up being a non-breaking
change.


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

Branch: refs/heads/TINKERPOP-1798
Commit: 0a06a86121ab5d3ac6d85531d75f70eba469cb01
Parents: 3648f80
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Fri Oct 20 12:20:52 2017 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Fri Oct 20 12:20:52 2017 -0400

----------------------------------------------------------------------
 CHANGELOG.asciidoc                              |  1 +
 .../upgrade/release-3.2.x-incubating.asciidoc   | 11 +++++
 .../bulkloading/BulkLoaderVertexProgram.java    |  8 +++-
 .../util/event/ConsoleMutationListener.java     |  5 +++
 .../traversal/step/util/event/Event.java        |  2 +-
 .../step/util/event/MutationListener.java       | 11 ++++-
 .../decoration/EventStrategyProcessTest.java    | 44 +++++++++++++++++++-
 7 files changed, 78 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0a06a861/CHANGELOG.asciidoc
----------------------------------------------------------------------
diff --git a/CHANGELOG.asciidoc b/CHANGELOG.asciidoc
index 07f1d69..504895c 100644
--- a/CHANGELOG.asciidoc
+++ b/CHANGELOG.asciidoc
@@ -35,6 +35,7 @@ image::https://raw.githubusercontent.com/apache/tinkerpop/master/docs/static/ima
 * Added better error message for illegal use of `repeat()`-step.
 * Fixed a bug in `RangeByIsCountStrategy` that led to unexpected behaviors when predicates
were used with floating point numbers.
 * Bump to Jackson 2.8.10.
+* Deprecated `MutationListener.vertexPropertyChanged()` method that did not use `VertexProperty`
and added a new method that does.
 * Added an `EmbeddedRemoteConnection` so that it's possible to mimic a remote connection
within the same JVM.
 * Supported interruption for remote traversals.
 * Allow the `:remote` command to accept a `Cluster` object defined in the console itself.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0a06a861/docs/src/upgrade/release-3.2.x-incubating.asciidoc
----------------------------------------------------------------------
diff --git a/docs/src/upgrade/release-3.2.x-incubating.asciidoc b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
index 732e29e..fcd193b 100644
--- a/docs/src/upgrade/release-3.2.x-incubating.asciidoc
+++ b/docs/src/upgrade/release-3.2.x-incubating.asciidoc
@@ -102,6 +102,17 @@ In `gremlin-test` there is a new `GraphHelper` class that has a `cloneElements()
 the first graph to the second - `GraphHelper.cloneElements(Graph original, Graph clone)`.
This helper method is
 primarily intended for use in tests.
 
+==== MutationListener Changes
+
+The `MutationListener` has a method called `vertexPropertyChanged` which gathered callbacks
when a property on a vertex
+was modified. The method had an incorrect signature though using `Property` instead of `VertexProperty`.
The old method
+that used `Property` has now been deprecated and a new method added that uses `VertexProperty`.
This new method has a
+default implementation that calls the old method, so this change should not cause breaks
in compilation on upgrade.
+Internally, TinkerPop no longer calls the old method except by way of that proxy. Users who
have `MutationListener`
+implementations can simply add the new method and override its behavior. The old method can
thus be ignored completely.
+
+See: link:https://issues.apache.org/jira/browse/TINKERPOP-1798[TINKERPOP-1798]
+
 == TinkerPop 3.2.6
 
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0a06a861/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
index a6d0f5b..508af3e 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/bulkloading/BulkLoaderVertexProgram.java
@@ -454,12 +454,18 @@ public class BulkLoaderVertexProgram implements VertexProgram<Tuple>
{
         }
 
         @Override
-        public void vertexPropertyChanged(final Vertex element, final Property oldValue,
final Object setValue,
+        public void vertexPropertyChanged(final Vertex element, final VertexProperty oldValue,
final Object setValue,
                                           final Object... vertexPropertyKeyValues) {
             this.counter++;
         }
 
         @Override
+        public void vertexPropertyChanged(final Vertex element, final Property oldValue,
final Object setValue,
+                                          final Object... vertexPropertyKeyValues) {
+            // do nothing - deprecated
+        }
+
+        @Override
         public void vertexPropertyRemoved(final VertexProperty vertexProperty) {
             this.counter++;
         }

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0a06a861/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/ConsoleMutationListener.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/ConsoleMutationListener.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/ConsoleMutationListener.java
index a45b195..937f414 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/ConsoleMutationListener.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/ConsoleMutationListener.java
@@ -84,6 +84,11 @@ public class ConsoleMutationListener implements MutationListener {
 
     @Override
     public void vertexPropertyChanged(final Vertex element, final Property oldValue, final
Object setValue, final Object... vertexPropertyKeyValues) {
+        // do nothing - deprecated
+    }
+
+    @Override
+    public void vertexPropertyChanged(final Vertex element, final VertexProperty oldValue,
final Object setValue, final Object... vertexPropertyKeyValues) {
         System.out.println("Vertex [" + element.toString() + "] property [" + oldValue +
"] change to [" + setValue + "] in graph [" + graph.toString() + "]");
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0a06a861/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/Event.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/Event.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/Event.java
index b5ed288..732c30b 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/Event.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/Event.java
@@ -139,7 +139,7 @@ public interface Event {
 
         @Override
         void fire(final MutationListener listener, final Element element, final Property
oldValue, final Object newValue, final Object... vertexPropertyKeyValues) {
-            listener.vertexPropertyChanged((Vertex) element, oldValue, newValue, vertexPropertyKeyValues);
+            listener.vertexPropertyChanged((Vertex) element, (VertexProperty) oldValue, newValue,
vertexPropertyKeyValues);
         }
     }
 

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0a06a861/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/MutationListener.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/MutationListener.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/MutationListener.java
index 422074c..00e49ed 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/MutationListener.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/step/util/event/MutationListener.java
@@ -52,10 +52,19 @@ public interface MutationListener {
     /**
      * Raised after the property of a {@link Vertex} changed.
      *
+     * @deprecated As of release 3.2.7, replaced by {@link #vertexPropertyChanged(Vertex,
VertexProperty, Object, Object...)}.
+     */
+    public void vertexPropertyChanged(final Vertex element, final Property oldValue, final
Object setValue, final Object... vertexPropertyKeyValues);
+
+    /**
+     * Raised after the property of a {@link Vertex} changed.
+     *
      * @param element  the {@link Vertex} that changed
      * @param setValue the new value of the property
      */
-    public void vertexPropertyChanged(final Vertex element, final Property oldValue, final
Object setValue, final Object... vertexPropertyKeyValues);
+    public default void vertexPropertyChanged(final Vertex element, final VertexProperty
oldValue, final Object setValue, final Object... vertexPropertyKeyValues) {
+        vertexPropertyChanged(element, (Property) oldValue, setValue, vertexPropertyKeyValues);
+    }
 
     /**
      * Raised after a {@link VertexProperty} was removed from the graph.

http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/0a06a861/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/EventStrategyProcessTest.java
----------------------------------------------------------------------
diff --git a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/EventStrategyProcessTest.java
b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/EventStrategyProcessTest.java
index 442847a..12a3e0a 100644
--- a/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/EventStrategyProcessTest.java
+++ b/gremlin-test/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/strategy/decoration/EventStrategyProcessTest.java
@@ -869,8 +869,10 @@ public class EventStrategyProcessTest extends AbstractGremlinProcessTest
{
         v.property("to-change", "blah");
 
         final MutationListener listener = new AbstractMutationListener() {
+
+
             @Override
-            public void vertexPropertyChanged(final Vertex element, final Property oldValue,
final Object setValue, final Object... vertexPropertyKeyValues) {
+            public void vertexPropertyChanged(final Vertex element, final VertexProperty
oldValue, final Object setValue, final Object... vertexPropertyKeyValues) {
                 assertEquals(label, element.label());
                 assertEquals(id, element.id());
                 assertEquals("to-change", oldValue.key());
@@ -905,6 +907,41 @@ public class EventStrategyProcessTest extends AbstractGremlinProcessTest
{
 
         final MutationListener listener = new AbstractMutationListener() {
             @Override
+            public void vertexPropertyChanged(final Vertex element, final VertexProperty
oldValue, final Object setValue, final Object... vertexPropertyKeyValues) {
+                assertEquals(label, element.label());
+                assertEquals(id, element.id());
+                assertEquals("new", oldValue.key());
+                assertEquals(null, oldValue.value());
+                assertEquals("dah", setValue);
+                triggered.set(true);
+            }
+        };
+        final EventStrategy.Builder builder = EventStrategy.build().addListener(listener);
+
+        if (graph.features().graph().supportsTransactions())
+            builder.eventQueue(new EventStrategy.TransactionalEventQueue(graph));
+
+        final EventStrategy eventStrategy = builder.create();
+        final GraphTraversalSource gts = create(eventStrategy);
+
+        gts.V(v).property(VertexProperty.Cardinality.single, "new", "dah").iterate();
+        tryCommit(graph);
+
+        assertEquals(2, IteratorUtils.count(g.V(v).properties()));
+        assertThat(triggered.get(), is(true));
+    }
+
+    @Test
+    @FeatureRequirementSet(FeatureRequirementSet.Package.VERTICES_ONLY)
+    public void shouldDetachVertexPropertyWhenNewDeprecated() {
+        final AtomicBoolean triggered = new AtomicBoolean(false);
+        final Vertex v = graph.addVertex();
+        final String label = v.label();
+        final Object id = v.id();
+        v.property("old","blah");
+
+        final MutationListener listener = new AbstractMutationListener() {
+            @Override
             public void vertexPropertyChanged(final Vertex element, final Property oldValue,
final Object setValue, final Object... vertexPropertyKeyValues) {
                 assertEquals(label, element.label());
                 assertEquals(id, element.id());
@@ -1133,6 +1170,11 @@ public class EventStrategyProcessTest extends AbstractGremlinProcessTest
{
 
         @Override
         public void vertexPropertyChanged(final Vertex element, final Property oldValue,
final Object setValue, final Object... vertexPropertyKeyValues) {
+            // do nothing - deprecated
+        }
+
+        @Override
+        public void vertexPropertyChanged(final Vertex element, final VertexProperty oldValue,
final Object setValue, final Object... vertexPropertyKeyValues) {
             vertexPropertyChangedEvent.incrementAndGet();
             order.add("v-property-changed-" + element.id());
         }


Mime
View raw message