From bec5ad02db190a9c28ac89a73bf8ebe67b72ca6c Mon Sep 17 00:00:00 2001 From: Robert Varga Date: Mon, 5 Jun 2017 23:12:41 +0200 Subject: [PATCH] Enable checkstyle on objectcache and mockito-config Just a few fixes and flip the switch. Change-Id: I83d8b9b4e959e03a912d2cbf4c3c26311af4fc0b Signed-off-by: Robert Varga --- common/mockito-configuration/pom.xml | 42 ++++++++++++------- .../ArgumentsExtractorVerifier.java | 4 +- common/object-cache-api/pom.xml | 33 +++++++++------ .../yangtools/objcache/ObjectCache.java | 1 + .../objcache/ObjectCacheFactory.java | 22 +++++----- .../objcache/spi/AbstractObjectCache.java | 2 + .../yangtools/objcache/spi/CacheTest.java | 5 +-- .../yangtools/objcache/spi/SoftKeyTest.java | 3 +- common/object-cache-guava/pom.xml | 33 +++++++++------ .../objcache/guava/GuavaObjectCache.java | 7 ++-- common/object-cache-noop/pom.xml | 33 +++++++++------ 11 files changed, 110 insertions(+), 75 deletions(-) diff --git a/common/mockito-configuration/pom.xml b/common/mockito-configuration/pom.xml index 5c3833620c..4bb8e13167 100644 --- a/common/mockito-configuration/pom.xml +++ b/common/mockito-configuration/pom.xml @@ -38,19 +38,31 @@ - - ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ - - - - opendaylight-site - ${nexus.site.url}/${project.artifactId}/ - - + + + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + + + + + + ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ + + + + opendaylight-site + ${nexus.site.url}/${project.artifactId}/ + + diff --git a/common/mockito-configuration/src/main/java/org/mockito/configuration/ArgumentsExtractorVerifier.java b/common/mockito-configuration/src/main/java/org/mockito/configuration/ArgumentsExtractorVerifier.java index d8983f40fb..ffc4a5d486 100644 --- a/common/mockito-configuration/src/main/java/org/mockito/configuration/ArgumentsExtractorVerifier.java +++ b/common/mockito-configuration/src/main/java/org/mockito/configuration/ArgumentsExtractorVerifier.java @@ -25,13 +25,15 @@ public class ArgumentsExtractorVerifier implements VerificationMode { InvocationsFinder finder = new InvocationsFinder(); List actualInvocations = finder.findInvocations(data.getAllInvocations(), data.getWanted()); if (actualInvocations.size() != 1) { - throw new MockitoException("This verifier can only be used with 1 invocation, got " + actualInvocations.size()); + throw new MockitoException("This verifier can only be used with 1 invocation, got " + + actualInvocations.size()); } Invocation invocation = actualInvocations.get(0); arguments = invocation.getArguments(); invocation.markVerified(); } + public Object[] getArguments() { return arguments; } diff --git a/common/object-cache-api/pom.xml b/common/object-cache-api/pom.xml index d0b08ce586..9b37956f15 100644 --- a/common/object-cache-api/pom.xml +++ b/common/object-cache-api/pom.xml @@ -85,22 +85,29 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + - - ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ + The following configuration is necessary for maven-site-plugin to + correctly identify the correct deployment path for OpenDaylight Maven + sites. + --> + ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ - - - opendaylight-site - ${nexus.site.url}/${project.artifactId}/ - - + + + opendaylight-site + ${nexus.site.url}/${project.artifactId}/ + + diff --git a/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/ObjectCache.java b/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/ObjectCache.java index 4e27592424..6390abcf86 100644 --- a/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/ObjectCache.java +++ b/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/ObjectCache.java @@ -19,6 +19,7 @@ import org.opendaylight.yangtools.concepts.ProductAwareBuilder; * indexes and spend some CPU cycles on walking the index to potentially * end up with a reused object. * + *

* Note that the cached objects should really be semantically {@link Immutable}. * This interface does not enforce that interface contract simply because * there are third-party objects which fulfill this contract. diff --git a/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/ObjectCacheFactory.java b/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/ObjectCacheFactory.java index 30edbf4d01..ac9087a899 100644 --- a/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/ObjectCacheFactory.java +++ b/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/ObjectCacheFactory.java @@ -27,19 +27,19 @@ public final class ObjectCacheFactory { @GuardedBy("this") private static synchronized IObjectCacheFactory initialize() { // Double-check under lock - IObjectCacheFactory f = factory; - if (f != null) { - return f; + IObjectCacheFactory fa = factory; + if (fa != null) { + return fa; } try { - f = StaticObjectCacheBinder.getInstance().getProductCacheFactory(); - factory = f; + fa = StaticObjectCacheBinder.getInstance().getProductCacheFactory(); + factory = fa; } catch (NoClassDefFoundError e) { - f = NoopObjectCacheBinder.INSTANCE.getProductCacheFactory(); + fa = NoopObjectCacheBinder.INSTANCE.getProductCacheFactory(); } - return f; + return fa; } public static synchronized void reset() { @@ -54,11 +54,11 @@ public final class ObjectCacheFactory { * @return Object cache instance. */ public static ObjectCache getObjectCache(@Nonnull final Class objClass) { - IObjectCacheFactory f = factory; - if (f == null) { - f = initialize(); + IObjectCacheFactory fa = factory; + if (fa == null) { + fa = initialize(); } - return f.getObjectCache(Preconditions.checkNotNull(objClass)); + return fa.getObjectCache(Preconditions.checkNotNull(objClass)); } } diff --git a/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/spi/AbstractObjectCache.java b/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/spi/AbstractObjectCache.java index 71eb2ca184..0bced73ded 100644 --- a/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/spi/AbstractObjectCache.java +++ b/common/object-cache-api/src/main/java/org/opendaylight/yangtools/objcache/spi/AbstractObjectCache.java @@ -64,9 +64,11 @@ public abstract class AbstractObjectCache implements ObjectCache { * Key used in the underlying map. It is essentially a soft reference, with * slightly special properties. * + *

* It acts as a proxy for the object it refers to and essentially delegates * to it. There are three exceptions here: * + *

* 1) This key needs to have a cached hash code. The requirement is that the * key needs to be able to look itself up after the reference to the object * has been cleared (and thus we can no longer look it up from there). One diff --git a/common/object-cache-api/src/test/java/org/opendaylight/yangtools/objcache/spi/CacheTest.java b/common/object-cache-api/src/test/java/org/opendaylight/yangtools/objcache/spi/CacheTest.java index 9b7fb55efd..57f835f9ff 100644 --- a/common/object-cache-api/src/test/java/org/opendaylight/yangtools/objcache/spi/CacheTest.java +++ b/common/object-cache-api/src/test/java/org/opendaylight/yangtools/objcache/spi/CacheTest.java @@ -11,14 +11,13 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotSame; import static org.junit.Assert.assertSame; +import com.google.common.base.FinalizableReferenceQueue; +import com.google.common.cache.CacheBuilder; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.opendaylight.yangtools.objcache.ObjectCache; -import com.google.common.base.FinalizableReferenceQueue; -import com.google.common.cache.CacheBuilder; - public class CacheTest { private FinalizableReferenceQueue queue; private ObjectCache oc; diff --git a/common/object-cache-api/src/test/java/org/opendaylight/yangtools/objcache/spi/SoftKeyTest.java b/common/object-cache-api/src/test/java/org/opendaylight/yangtools/objcache/spi/SoftKeyTest.java index dc16f77e92..3caaf65220 100644 --- a/common/object-cache-api/src/test/java/org/opendaylight/yangtools/objcache/spi/SoftKeyTest.java +++ b/common/object-cache-api/src/test/java/org/opendaylight/yangtools/objcache/spi/SoftKeyTest.java @@ -13,13 +13,12 @@ import static org.junit.Assert.assertNull; import static org.junit.Assert.assertSame; import static org.junit.Assert.assertTrue; +import com.google.common.base.FinalizableReferenceQueue; import org.junit.After; import org.junit.Before; import org.junit.Test; import org.opendaylight.yangtools.objcache.spi.AbstractObjectCache.SoftKey; -import com.google.common.base.FinalizableReferenceQueue; - public class SoftKeyTest { private FinalizableReferenceQueue queue; diff --git a/common/object-cache-guava/pom.xml b/common/object-cache-guava/pom.xml index 06cd078148..e3bcb1edcd 100644 --- a/common/object-cache-guava/pom.xml +++ b/common/object-cache-guava/pom.xml @@ -67,22 +67,29 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + - - ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ + The following configuration is necessary for maven-site-plugin to + correctly identify the correct deployment path for OpenDaylight Maven + sites. + --> + ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ - - - opendaylight-site - ${nexus.site.url}/${project.artifactId}/ - - + + + opendaylight-site + ${nexus.site.url}/${project.artifactId}/ + + diff --git a/common/object-cache-guava/src/main/java/org/opendaylight/yangtools/objcache/guava/GuavaObjectCache.java b/common/object-cache-guava/src/main/java/org/opendaylight/yangtools/objcache/guava/GuavaObjectCache.java index 5d0e2589ef..6ee1a274f3 100644 --- a/common/object-cache-guava/src/main/java/org/opendaylight/yangtools/objcache/guava/GuavaObjectCache.java +++ b/common/object-cache-guava/src/main/java/org/opendaylight/yangtools/objcache/guava/GuavaObjectCache.java @@ -7,18 +7,17 @@ */ package org.opendaylight.yangtools.objcache.guava; -import org.opendaylight.yangtools.objcache.spi.AbstractObjectCache; - import com.google.common.base.FinalizableReferenceQueue; import com.google.common.cache.CacheBuilder; import com.google.common.cache.CacheBuilderSpec; +import org.opendaylight.yangtools.objcache.spi.AbstractObjectCache; final class GuavaObjectCache extends AbstractObjectCache { - public GuavaObjectCache(final FinalizableReferenceQueue queue) { + GuavaObjectCache(final FinalizableReferenceQueue queue) { super(CacheBuilder.newBuilder().softValues().build(), queue); } - public GuavaObjectCache(final FinalizableReferenceQueue queue, final CacheBuilderSpec spec) { + GuavaObjectCache(final FinalizableReferenceQueue queue, final CacheBuilderSpec spec) { super(CacheBuilder.from(spec).build(), queue); } } diff --git a/common/object-cache-noop/pom.xml b/common/object-cache-noop/pom.xml index 58d8cf0297..9ffa0fe38c 100644 --- a/common/object-cache-noop/pom.xml +++ b/common/object-cache-noop/pom.xml @@ -56,22 +56,29 @@ + + org.apache.maven.plugins + maven-checkstyle-plugin + + checkstyle.violationSeverity=error + + - - ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ + The following configuration is necessary for maven-site-plugin to + correctly identify the correct deployment path for OpenDaylight Maven + sites. + --> + ${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/ - - - opendaylight-site - ${nexus.site.url}/${project.artifactId}/ - - + + + opendaylight-site + ${nexus.site.url}/${project.artifactId}/ + + -- 2.36.6