tinkerpop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From spmalle...@apache.org
Subject [4/6] tinkerpop git commit: TINKERPOP-1595 Refactored reflective lookups for clone()
Date Tue, 24 Apr 2018 12:10:48 GMT
TINKERPOP-1595 Refactored reflective lookups for clone()

Rather than iterate all methods to find clone() just call getMethod() and call that if found.
Nothing seems to be exercising this bit of code in our test suite. I forced it by adding clone()
temporarily to RangeBiOperator and it worked without issue. Not sure how else to test this.


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

Branch: refs/heads/TINKERPOP-1595
Commit: d61765e81636f1c019fc0dc1406cd80de53ce6fa
Parents: e92bd70
Author: Stephen Mallette <spmva@genoprime.com>
Authored: Tue Apr 24 08:03:28 2018 -0400
Committer: Stephen Mallette <spmva@genoprime.com>
Committed: Tue Apr 24 08:03:28 2018 -0400

----------------------------------------------------------------------
 .../gremlin/process/computer/MemoryComputeKey.java   | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tinkerpop/blob/d61765e8/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/MemoryComputeKey.java
----------------------------------------------------------------------
diff --git a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/MemoryComputeKey.java
b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/MemoryComputeKey.java
index 70adf3d..a9b1532 100644
--- a/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/MemoryComputeKey.java
+++ b/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/computer/MemoryComputeKey.java
@@ -79,14 +79,17 @@ public final class MemoryComputeKey<A> implements Serializable,
Cloneable {
     public MemoryComputeKey<A> clone() {
         try {
             final MemoryComputeKey<A> clone = (MemoryComputeKey<A>) super.clone();
-            for (final Method method : this.reducer.getClass().getMethods()) {
-                if (method.getName().equals("clone") && 0 == method.getParameterCount())
{
-                    clone.reducer = (BinaryOperator<A>) method.invoke(this.reducer);
-                    break;
-                }
+
+            try {
+                final Method cloneMethod = this.reducer.getClass().getMethod("clone");
+                if (cloneMethod != null)
+                    clone.reducer = (BinaryOperator<A>) cloneMethod.invoke(this.reducer);
+            } catch(Exception ignored) {
+
             }
+
             return clone;
-        } catch (final IllegalAccessException | InvocationTargetException | CloneNotSupportedException
e) {
+        } catch (final CloneNotSupportedException e) {
             throw new IllegalStateException(e.getMessage(), e);
         }
     }


Mime
View raw message