cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sn...@apache.org
Subject [1/2] cassandra git commit: jacoco instrumentation breaks UDF validation
Date Mon, 09 Nov 2015 11:46:59 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-3.0 96f407bce -> f2af290c5


jacoco instrumentation breaks UDF validation

patch by Russ Hatch; reviewed by Robert Stupp for CASSANDRA-10672


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

Branch: refs/heads/cassandra-3.0
Commit: b5b1252ce1d2f81a51801a1b62bcf0b86fdf7238
Parents: 59a3221
Author: Russ Hatch <rhatch@datastax.com>
Authored: Mon Nov 9 12:43:59 2015 +0100
Committer: Robert Stupp <snazy@snazy.de>
Committed: Mon Nov 9 12:43:59 2015 +0100

----------------------------------------------------------------------
 .../cassandra/cql3/functions/JavaSourceUDFFactory.java | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/b5b1252c/src/java/org/apache/cassandra/cql3/functions/JavaSourceUDFFactory.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/cql3/functions/JavaSourceUDFFactory.java b/src/java/org/apache/cassandra/cql3/functions/JavaSourceUDFFactory.java
index c40e031..515c947 100644
--- a/src/java/org/apache/cassandra/cql3/functions/JavaSourceUDFFactory.java
+++ b/src/java/org/apache/cassandra/cql3/functions/JavaSourceUDFFactory.java
@@ -24,6 +24,7 @@ import java.lang.invoke.MethodHandle;
 import java.lang.invoke.MethodHandles;
 import java.lang.invoke.MethodType;
 import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
@@ -222,7 +223,17 @@ public final class JavaSourceUDFFactory
 
             Class cls = targetClassLoader.loadClass(targetClassName);
 
-            if (cls.getDeclaredMethods().length != 2 || cls.getDeclaredConstructors().length
!= 1)
+            // Count only non-synthetic methods, so code coverage instrumentation doesn't
cause a miscount
+            int nonSyntheticMethodCount = 0;
+            for (Method m : cls.getDeclaredMethods())
+            {
+                if (!m.isSynthetic())
+                {
+                    nonSyntheticMethodCount += 1;
+                }
+            }
+
+            if (nonSyntheticMethodCount != 2 || cls.getDeclaredConstructors().length != 1)
                 throw new InvalidRequestException("Check your source to not define additional
Java methods or constructors");
             MethodType methodType = MethodType.methodType(void.class)
                                               .appendParameterTypes(FunctionName.class, List.class,
List.class, DataType[].class,


Mime
View raw message