From 9aeafe30b7d932e562f803fd071812cd27aebaf8 Mon Sep 17 00:00:00 2001 From: Sean Busbey Date: Fri, 1 May 2015 23:53:13 -0500 Subject: [PATCH] HBASE-13611 update clover profile to work with clover 4.x and maven 3. * change pom to use a maven 3 compat version of clover * add clover to javadoc plugin deps so that instrumented doclet works * modify IA annotation test to filter out clover instrumentation * make splitlog counters check for atomiclong before casting --- .../TestInterfaceAudienceAnnotations.java | 27 ++++++++++++++++++- .../apache/hadoop/hbase/SplitLogCounters.java | 5 +++- pom.xml | 22 +++++++++++---- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java b/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java index ace11ec16f6..be79278cc31 100644 --- a/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java +++ b/hbase-client/src/test/java/org/apache/hadoop/hbase/TestInterfaceAudienceAnnotations.java @@ -198,6 +198,29 @@ public class TestInterfaceAudienceAnnotations { } } + /** + * Selects classes that appear to be source instrumentation from Clover. + * Clover generates instrumented code in order to calculate coverage. Part of the + * generated source is a static inner class on each source class. + * + * - has an enclosing class + * - enclosing class is not an interface + * - name starts with "__CLR" + */ + class CloverInstrumentationFilter implements ClassFinder.ClassFilter { + @Override + public boolean isCandidateClass(Class clazz) { + boolean clover = false; + final Class enclosing = clazz.getEnclosingClass(); + if (enclosing != null) { + if (!(enclosing.isInterface())) { + clover = clazz.getSimpleName().startsWith("__CLR"); + } + } + return clover; + } + } + /** * Checks whether all the classes in client and common modules contain * {@link InterfaceAudience} annotations. @@ -212,6 +235,7 @@ public class TestInterfaceAudienceAnnotations { // NOT test classes // AND NOT generated classes // AND are NOT annotated with InterfaceAudience + // AND are NOT from Clover rewriting sources ClassFinder classFinder = new ClassFinder( new MainCodeResourcePathFilter(), new Not((FileNameFilter)new TestFileNameFilter()), @@ -219,7 +243,8 @@ public class TestInterfaceAudienceAnnotations { new Not(new TestClassFilter()), new Not(new GeneratedClassFilter()), new Not(new IsInterfaceStabilityClassFilter()), - new Not(new InterfaceAudienceAnnotatedClassFilter())) + new Not(new InterfaceAudienceAnnotatedClassFilter()), + new Not(new CloverInstrumentationFilter())) ); Set> classes = classFinder.findClasses(false); diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogCounters.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogCounters.java index 6af5045a12c..bde1b885431 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogCounters.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/SplitLogCounters.java @@ -88,7 +88,10 @@ public class SplitLogCounters { public static void resetCounters() throws Exception { Class cl = SplitLogCounters.class; for (Field fld : cl.getDeclaredFields()) { - if (!fld.isSynthetic()) ((AtomicLong)fld.get(null)).set(0); + /* Guard against source instrumentation. */ + if ((!fld.isSynthetic()) && (AtomicLong.class.isAssignableFrom(fld.getType()))) { + ((AtomicLong)fld.get(null)).set(0); + } } } } diff --git a/pom.xml b/pom.xml index 333dc56c406..814502bb242 100644 --- a/pom.xml +++ b/pom.xml @@ -1166,7 +1166,7 @@ 3.4.6 1.7.7 0.0.1-SNAPSHOT - 2.6.3 + 4.0.3 2.3.1 1.3.3 4.0.23.Final @@ -2572,9 +2572,8 @@ + The report will be generated under target/site/clover/index.html when you run + MAVEN_OPTS="-Xmx2048m -XX:MaxPermSize=512m" mvn clean package -Pclover site --> clover @@ -2585,10 +2584,23 @@ ${user.home}/.clover.license - 2.6.3 + + + org.apache.maven.plugins + maven-javadoc-plugin + + + com.atlassian.maven.plugins + maven-clover2-plugin + ${clover.version} + + + com.atlassian.maven.plugins maven-clover2-plugin