From fe68b00ac52b303dd20231123d61e7c3e03782ac Mon Sep 17 00:00:00 2001 From: Ben Manes Date: Sun, 6 Nov 2016 14:02:45 -0800 Subject: [PATCH] Add Coverity build scan Fixed minor compilation errors in their static analysis. But the plugin assumes a commercial installation for local analysis. The open-source portal doesn't seem to accept the emit-db due to not having a build-log.txt file. So more debugging is required to figure out how to integrate with Coverity Scan. Despite that, merging since the changes were benign and we might get it working in the future. --- build.gradle | 1 + .../benmanes/caffeine/base/UnsafeAccess.java | 2 +- .../benmanes/caffeine/cache/CaffeineTest.java | 4 +-- .../caffeine/cache/testing/CacheContext.java | 12 +++++--- .../testing/CaffeineCacheFromContext.java | 6 +++- .../caffeine/cache/testing/FakeTicker.java | 28 ------------------- .../cache/testing/GuavaCacheFromContext.java | 4 +-- gradle/dependencies.gradle | 2 ++ .../caffeine/guava/CaffeinatedGuava.java | 6 ++-- .../common/cache/CacheBuilderGwtTest.java | 23 +++++++-------- .../common/cache/CacheExpirationTest.java | 23 +++++++-------- .../google/common/cache/CacheLoadingTest.java | 13 +++++---- .../google/common/cache/CacheRefreshTest.java | 6 ++-- .../com/google/common/cache/FakeTicker.java | 28 ------------------- simulator/build.gradle | 4 +++ 15 files changed, 63 insertions(+), 99 deletions(-) delete mode 100644 caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/FakeTicker.java delete mode 100644 guava/src/test/java/com/google/common/cache/FakeTicker.java diff --git a/build.gradle b/build.gradle index e90942a41c..8e97cb623d 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,4 @@ +apply plugin: 'com.github.mjdetullio.gradle.coverity' apply plugin: 'com.github.ben-manes.versions' apply plugin: 'com.github.kt3k.coveralls' apply plugin: 'jacoco' diff --git a/caffeine/src/main/java/com/github/benmanes/caffeine/base/UnsafeAccess.java b/caffeine/src/main/java/com/github/benmanes/caffeine/base/UnsafeAccess.java index 8a748e0717..d55c9429ee 100644 --- a/caffeine/src/main/java/com/github/benmanes/caffeine/base/UnsafeAccess.java +++ b/caffeine/src/main/java/com/github/benmanes/caffeine/base/UnsafeAccess.java @@ -63,7 +63,7 @@ public static long objectFieldOffset(Class clazz, String fieldName) { static Unsafe load(String openJdk, String android) throws NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException { - Field field = null; + Field field; try { // try OpenJDK field name field = Unsafe.class.getDeclaredField(openJdk); diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CaffeineTest.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CaffeineTest.java index b10263afc9..045cb0f10d 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CaffeineTest.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/CaffeineTest.java @@ -34,7 +34,7 @@ import com.github.benmanes.caffeine.cache.Policy.Eviction; import com.github.benmanes.caffeine.cache.Policy.Expiration; import com.github.benmanes.caffeine.cache.stats.StatsCounter; -import com.github.benmanes.caffeine.cache.testing.FakeTicker; +import com.google.common.testing.FakeTicker; import com.google.common.util.concurrent.MoreExecutors; /** @@ -449,7 +449,7 @@ public void ticker_twice() { @Test public void ticker() { - Ticker ticker = new FakeTicker(); + Ticker ticker = new FakeTicker()::read; Caffeine builder = Caffeine.newBuilder().ticker(ticker); assertThat(builder.ticker, is(ticker)); builder.build(); diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContext.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContext.java index 6d5cc0e88b..005bf88a44 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContext.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CacheContext.java @@ -22,6 +22,7 @@ import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.nullValue; +import java.io.Serializable; import java.util.Collections; import java.util.LinkedHashMap; import java.util.List; @@ -61,6 +62,7 @@ import com.google.common.base.MoreObjects; import com.google.common.cache.CacheBuilder; import com.google.common.collect.ImmutableSet; +import com.google.common.testing.FakeTicker; /** * The cache configuration context for a test case. @@ -134,7 +136,7 @@ public CacheContext(InitialCapacity initialCapacity, Stats stats, CacheWeigher w this.isAsyncLoading = isAsyncLoading; this.writer = requireNonNull(writer); this.cacheWriter = writer.get(); - this.ticker = new FakeTicker(); + this.ticker = new SerializableFakeTicker(); this.implementation = requireNonNull(implementation); this.original = new LinkedHashMap<>(); this.initialSize = -1; @@ -371,14 +373,13 @@ public FakeTicker ticker() { } public LoadingCache build(CacheLoader loader) { - LoadingCache cache = null; + LoadingCache cache; if (isCaffeine()) { cache = isAsync() ? caffeine.buildAsync(loader).synchronous() : caffeine.build(loader); } else { cache = new GuavaLoadingCache<>(guava.build( com.google.common.cache.CacheLoader.asyncReloading( - new SingleLoader<>(loader), executor)), - ticker, isRecordingStats()); + new SingleLoader<>(loader), executor)), ticker, isRecordingStats()); } this.cache = cache; return cache; @@ -440,4 +441,7 @@ public String toString() { .add("implementation", implementation) .toString(); } + + @SuppressWarnings("serial") + static final class SerializableFakeTicker extends FakeTicker implements Serializable {} } diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CaffeineCacheFromContext.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CaffeineCacheFromContext.java index c8c3c9c45e..44ef795af1 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CaffeineCacheFromContext.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/CaffeineCacheFromContext.java @@ -15,11 +15,13 @@ */ package com.github.benmanes.caffeine.cache.testing; +import java.io.Serializable; import java.util.concurrent.TimeUnit; import com.github.benmanes.caffeine.cache.Cache; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.cache.RandomSeedEnforcer; +import com.github.benmanes.caffeine.cache.Ticker; import com.github.benmanes.caffeine.cache.testing.CacheSpec.CacheExecutor; import com.github.benmanes.caffeine.cache.testing.CacheSpec.CacheWeigher; import com.github.benmanes.caffeine.cache.testing.CacheSpec.Expire; @@ -34,6 +36,7 @@ * @author ben.manes@gmail.com (Ben Manes) */ public final class CaffeineCacheFromContext { + interface SerializableTicker extends Ticker, Serializable {} private CaffeineCacheFromContext() {} @@ -65,7 +68,8 @@ public static Cache newCaffeineCache(CacheContext context) { builder.refreshAfterWrite(context.refresh.timeNanos(), TimeUnit.NANOSECONDS); } if (context.expires() || context.refreshes()) { - builder.ticker(context.ticker()); + SerializableTicker ticker = context.ticker()::read; + builder.ticker(ticker); } if (context.keyStrength == ReferenceType.WEAK) { builder.weakKeys(); diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/FakeTicker.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/FakeTicker.java deleted file mode 100644 index 73a4e5bb8a..0000000000 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/FakeTicker.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2014 Ben Manes. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.github.benmanes.caffeine.cache.testing; - -import java.io.Serializable; - -import com.github.benmanes.caffeine.cache.Ticker; - -/** - * @author ben.manes@gmail.com (Ben Manes) - */ -public final class FakeTicker extends com.google.common.testing.FakeTicker - implements Ticker, Serializable { - private static final long serialVersionUID = 1L; -} diff --git a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/GuavaCacheFromContext.java b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/GuavaCacheFromContext.java index 4d9e9409fd..0a95fae51f 100644 --- a/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/GuavaCacheFromContext.java +++ b/caffeine/src/test/java/com/github/benmanes/caffeine/cache/testing/GuavaCacheFromContext.java @@ -35,7 +35,6 @@ import com.github.benmanes.caffeine.cache.LoadingCache; import com.github.benmanes.caffeine.cache.Policy; import com.github.benmanes.caffeine.cache.RemovalCause; -import com.github.benmanes.caffeine.cache.Ticker; import com.github.benmanes.caffeine.cache.stats.CacheStats; import com.github.benmanes.caffeine.cache.testing.CacheSpec.CacheWeigher; import com.github.benmanes.caffeine.cache.testing.CacheSpec.Expire; @@ -43,6 +42,7 @@ import com.github.benmanes.caffeine.cache.testing.CacheSpec.Listener; import com.github.benmanes.caffeine.cache.testing.CacheSpec.Maximum; import com.github.benmanes.caffeine.cache.testing.CacheSpec.ReferenceType; +import com.google.common.base.Ticker; import com.google.common.cache.AbstractCache.SimpleStatsCounter; import com.google.common.cache.AbstractCache.StatsCounter; import com.google.common.cache.CacheBuilder; @@ -113,7 +113,7 @@ public static Cache newGuavaCache(CacheContext context) { builder.removalListener(new GuavaRemovalListener<>( translateZeroExpire, context.removalListener)); } - Ticker ticker = (context.ticker == null) ? Ticker.systemTicker() : context.ticker; + Ticker ticker = (context.ticker == null) ? Ticker.systemTicker() : context.ticker(); if (context.loader == null) { context.cache = new GuavaCache<>(builder.build(), ticker, context.isRecordingStats()); diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 215f30e008..011fa6d2b6 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -71,6 +71,7 @@ ext { plugin_versions = [ checkstyle: '7.2', coveralls: '2.6.3', + coverity: '1.0.10', extra_conf: '3.1.0', error_prone: '0.0.8', huntbugs_core: '0.0.11', @@ -164,6 +165,7 @@ ext { transitive = false }, coveralls: "org.kt3k.gradle.plugin:coveralls-gradle-plugin:${plugin_versions.coveralls}", + coverity: "gradle.plugin.com.github.mjdetullio.gradle:coverity-plugin:${plugin_versions.coverity}", extra_conf: "com.netflix.nebula:gradle-extra-configurations-plugin:${plugin_versions.extra_conf}", error_prone: "net.ltgt.gradle:gradle-errorprone-plugin:${plugin_versions.error_prone}", huntbugs: [ diff --git a/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuava.java b/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuava.java index 391f89eb6a..e3525ffa06 100644 --- a/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuava.java +++ b/guava/src/main/java/com/github/benmanes/caffeine/guava/CaffeinatedGuava.java @@ -42,7 +42,7 @@ private CaffeinatedGuava() {} * @return a cache exposed under the Guava APIs */ @Nonnull - public static Cache build( + public static Cache build( @Nonnull Caffeine builder) { return new CaffeinatedGuavaCache<>(builder.build()); } @@ -55,7 +55,7 @@ public static Cache build( * @return a cache exposed under the Guava APIs */ @Nonnull - public static LoadingCache build( + public static LoadingCache build( @Nonnull Caffeine builder, @Nonnull CacheLoader loader) { @SuppressWarnings("unchecked") CacheLoader castedLoader = (CacheLoader) loader; @@ -72,7 +72,7 @@ public static LoadingCache build( * @return a cache exposed under the Guava APIs */ @Nonnull - public static LoadingCache build( + public static LoadingCache build( @Nonnull Caffeine builder, @Nonnull com.github.benmanes.caffeine.cache.CacheLoader loader) { return new CaffeinatedGuavaLoadingCache<>(builder.build(loader)); diff --git a/guava/src/test/java/com/google/common/cache/CacheBuilderGwtTest.java b/guava/src/test/java/com/google/common/cache/CacheBuilderGwtTest.java index 627cac5fc2..9fad2d6f52 100644 --- a/guava/src/test/java/com/google/common/cache/CacheBuilderGwtTest.java +++ b/guava/src/test/java/com/google/common/cache/CacheBuilderGwtTest.java @@ -35,6 +35,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; import com.google.common.collect.Sets; +import com.google.common.testing.FakeTicker; import com.google.common.util.concurrent.MoreExecutors; import junit.framework.TestCase; @@ -148,7 +149,7 @@ public void testExpireAfterAccess() { final Cache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterAccess(1000, TimeUnit.MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(fakeTicker)); + .ticker(fakeTicker::read)); cache.put(0, 10); cache.put(2, 30); @@ -165,7 +166,7 @@ public void testExpireAfterWrite() { final Cache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterWrite(1000, TimeUnit.MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(fakeTicker)); + .ticker(fakeTicker::read)); cache.put(10, 100); cache.put(20, 200); @@ -193,7 +194,7 @@ public void testExpireAfterWriteAndAccess() { .expireAfterWrite(1000, TimeUnit.MILLISECONDS) .expireAfterAccess(500, TimeUnit.MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(fakeTicker)); + .ticker(fakeTicker::read)); cache.put(10, 100); cache.put(20, 200); @@ -291,7 +292,7 @@ public void onRemoval(Integer key, Integer value, RemovalCause cause) { .executor(MoreExecutors.directExecutor()) .removalListener(countingListener) .initialCapacity(100) - .ticker(fakeTicker) + .ticker(fakeTicker::read) .maximumSize(2)); // Enforce full initialization of internal structures @@ -390,7 +391,7 @@ public void testAsMap_containsValue() { Cache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterWrite(20000, TimeUnit.MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(fakeTicker)); + .ticker(fakeTicker::read)); cache.put(654, 2675); fakeTicker.advance(10000, TimeUnit.MILLISECONDS); @@ -408,7 +409,7 @@ public void testAsMap_containsKey() { Cache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterWrite(20000, TimeUnit.MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(fakeTicker)); + .ticker(fakeTicker::read)); cache.put(654, 2675); fakeTicker.advance(10000, TimeUnit.MILLISECONDS); @@ -426,7 +427,7 @@ public void testAsMapValues_contains() { Cache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterWrite(1000, TimeUnit.MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(fakeTicker)); + .ticker(fakeTicker::read)); cache.put(10, 20); fakeTicker.advance(500, TimeUnit.MILLISECONDS); @@ -444,7 +445,7 @@ public void testAsMapKeySet() { Cache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterWrite(1000, TimeUnit.MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(fakeTicker)); + .ticker(fakeTicker::read)); cache.put(10, 20); fakeTicker.advance(500, TimeUnit.MILLISECONDS); @@ -466,7 +467,7 @@ public void testAsMapKeySet_contains() { Cache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterWrite(1000, TimeUnit.MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(fakeTicker)); + .ticker(fakeTicker::read)); cache.put(10, 20); fakeTicker.advance(500, TimeUnit.MILLISECONDS); @@ -484,7 +485,7 @@ public void testAsMapEntrySet() { Cache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterWrite(1000, TimeUnit.MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(fakeTicker)); + .ticker(fakeTicker::read)); cache.put(10, 20); fakeTicker.advance(500, TimeUnit.MILLISECONDS); @@ -504,7 +505,7 @@ public void testAsMapValues_iteratorRemove() { Cache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterWrite(1000, TimeUnit.MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(fakeTicker)); + .ticker(fakeTicker::read)); cache.put(10, 20); Iterator iterator = cache.asMap().values().iterator(); diff --git a/guava/src/test/java/com/google/common/cache/CacheExpirationTest.java b/guava/src/test/java/com/google/common/cache/CacheExpirationTest.java index ffb0bf6543..40e5521c58 100644 --- a/guava/src/test/java/com/google/common/cache/CacheExpirationTest.java +++ b/guava/src/test/java/com/google/common/cache/CacheExpirationTest.java @@ -32,6 +32,7 @@ import com.google.common.cache.TestingCacheLoaders.IdentityLoader; import com.google.common.cache.TestingRemovalListeners.CountingRemovalListener; import com.google.common.collect.Iterators; +import com.google.common.testing.FakeTicker; import com.google.common.util.concurrent.Callables; import com.google.common.util.concurrent.MoreExecutors; @@ -57,7 +58,7 @@ public void testExpiration_expireAfterWrite() { .expireAfterWrite(EXPIRING_TIME, MILLISECONDS) .executor(MoreExecutors.directExecutor()) .removalListener(removalListener) - .ticker(ticker), + .ticker(ticker::read), loader); checkExpiration(cache, loader, ticker, removalListener); } @@ -70,7 +71,7 @@ public void testExpiration_expireAfterAccess() { .expireAfterAccess(EXPIRING_TIME, MILLISECONDS) .executor(MoreExecutors.directExecutor()) .removalListener(removalListener) - .ticker(ticker), + .ticker(ticker::read), loader); checkExpiration(cache, loader, ticker, removalListener); } @@ -108,7 +109,7 @@ public void testExpiringGet_expireAfterWrite() { .expireAfterWrite(EXPIRING_TIME, MILLISECONDS) .executor(MoreExecutors.directExecutor()) .removalListener(removalListener) - .ticker(ticker), + .ticker(ticker::read), loader); runExpirationTest(cache, loader, ticker, removalListener); } @@ -121,7 +122,7 @@ public void testExpiringGet_expireAfterAccess() { .expireAfterAccess(EXPIRING_TIME, MILLISECONDS) .executor(MoreExecutors.directExecutor()) .removalListener(removalListener) - .ticker(ticker), + .ticker(ticker::read), loader); runExpirationTest(cache, loader, ticker, removalListener); } @@ -203,7 +204,7 @@ public void onRemoval(Integer key, AtomicInteger value, RemovalCause cause) { .removalListener(removalListener) .expireAfterWrite(10, MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(ticker), + .ticker(ticker::read), loader); // Increment 100 times @@ -225,7 +226,7 @@ public void testRemovalScheduler_expireAfterWrite() { .expireAfterWrite(EXPIRING_TIME, MILLISECONDS) .executor(MoreExecutors.directExecutor()) .removalListener(removalListener) - .ticker(ticker), + .ticker(ticker::read), loader); runRemovalScheduler(cache, removalListener, loader, ticker, KEY_PREFIX, EXPIRING_TIME); } @@ -238,7 +239,7 @@ public void testRemovalScheduler_expireAfterAccess() { .expireAfterAccess(EXPIRING_TIME, MILLISECONDS) .executor(MoreExecutors.directExecutor()) .removalListener(removalListener) - .ticker(ticker), + .ticker(ticker::read), loader); runRemovalScheduler(cache, removalListener, loader, ticker, KEY_PREFIX, EXPIRING_TIME); } @@ -252,7 +253,7 @@ public void testRemovalScheduler_expireAfterBoth() { .expireAfterWrite(EXPIRING_TIME, MILLISECONDS) .executor(MoreExecutors.directExecutor()) .removalListener(removalListener) - .ticker(ticker), + .ticker(ticker::read), loader); runRemovalScheduler(cache, removalListener, loader, ticker, KEY_PREFIX, EXPIRING_TIME); } @@ -263,7 +264,7 @@ public void testExpirationOrder_access() { IdentityLoader loader = identityLoader(); LoadingCache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterAccess(11, MILLISECONDS) - .ticker(ticker), + .ticker(ticker::read), loader); for (int i = 0; i < 10; i++) { cache.getUnchecked(i); @@ -314,7 +315,7 @@ public void testExpirationOrder_write() throws ExecutionException { IdentityLoader loader = identityLoader(); LoadingCache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterWrite(11, MILLISECONDS) - .ticker(ticker), + .ticker(ticker::read), loader); for (int i = 0; i < 10; i++) { cache.getUnchecked(i); @@ -361,7 +362,7 @@ public void testExpirationOrder_writeAccess() throws ExecutionException { LoadingCache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .expireAfterWrite(5, MILLISECONDS) .expireAfterAccess(3, MILLISECONDS) - .ticker(ticker), + .ticker(ticker::read), loader); for (int i = 0; i < 5; i++) { cache.getUnchecked(i); diff --git a/guava/src/test/java/com/google/common/cache/CacheLoadingTest.java b/guava/src/test/java/com/google/common/cache/CacheLoadingTest.java index c399bbcee2..90fa5b901f 100644 --- a/guava/src/test/java/com/google/common/cache/CacheLoadingTest.java +++ b/guava/src/test/java/com/google/common/cache/CacheLoadingTest.java @@ -46,6 +46,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.testing.FakeTicker; import com.google.common.testing.TestLogHandler; import com.google.common.util.concurrent.Callables; import com.google.common.util.concurrent.ExecutionError; @@ -218,7 +219,7 @@ public ListenableFuture reload(Object key, Object oldValue) { LoadingCache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .recordStats() - .ticker(ticker) + .ticker(ticker::read) .refreshAfterWrite(1, MILLISECONDS) .executor(MoreExecutors.directExecutor()), loader); @@ -280,7 +281,7 @@ public ListenableFuture reload(Object key, Object oldValue) { LoadingCache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .recordStats() - .ticker(ticker) + .ticker(ticker::read) .refreshAfterWrite(1, MILLISECONDS) .executor(MoreExecutors.directExecutor()), loader); @@ -757,7 +758,7 @@ public ListenableFuture reload(Object key, Object oldValue) { LoadingCache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .recordStats() - .ticker(ticker) + .ticker(ticker::read) .refreshAfterWrite(1, MILLISECONDS) .executor(MoreExecutors.directExecutor()), loader); Object key = new Object(); @@ -1037,7 +1038,7 @@ public ListenableFuture reload(Object key, Object oldValue) { LoadingCache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .recordStats() - .ticker(ticker) + .ticker(ticker::read) .refreshAfterWrite(1, MILLISECONDS) .executor(MoreExecutors.directExecutor()), loader); @@ -1363,7 +1364,7 @@ public ListenableFuture reload(Object key, Object oldValue) { LoadingCache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .recordStats() - .ticker(ticker) + .ticker(ticker::read) .refreshAfterWrite(1, MILLISECONDS) .executor(MoreExecutors.directExecutor()), loader); @@ -1637,7 +1638,7 @@ public ListenableFuture reload(Object key, Object oldValue) { LoadingCache cache = CaffeinatedGuava.build(Caffeine.newBuilder() .recordStats() - .ticker(ticker) + .ticker(ticker::read) .refreshAfterWrite(1, MILLISECONDS) .executor(MoreExecutors.directExecutor()), loader); diff --git a/guava/src/test/java/com/google/common/cache/CacheRefreshTest.java b/guava/src/test/java/com/google/common/cache/CacheRefreshTest.java index dda946298b..e32fcf1790 100644 --- a/guava/src/test/java/com/google/common/cache/CacheRefreshTest.java +++ b/guava/src/test/java/com/google/common/cache/CacheRefreshTest.java @@ -16,13 +16,15 @@ import static com.google.common.cache.TestingCacheLoaders.incrementingLoader; import static java.util.concurrent.TimeUnit.MILLISECONDS; -import junit.framework.TestCase; import com.github.benmanes.caffeine.cache.Caffeine; import com.github.benmanes.caffeine.guava.CaffeinatedGuava; import com.google.common.cache.TestingCacheLoaders.IncrementingLoader; +import com.google.common.testing.FakeTicker; import com.google.common.util.concurrent.MoreExecutors; +import junit.framework.TestCase; + /** * Tests relating to automatic cache refreshing. * @@ -36,7 +38,7 @@ public void testAutoRefresh() { .refreshAfterWrite(3, MILLISECONDS) .expireAfterWrite(6, MILLISECONDS) .executor(MoreExecutors.directExecutor()) - .ticker(ticker), loader); + .ticker(ticker::read), loader); int expectedLoads = 0; int expectedReloads = 0; for (int i = 0; i < 3; i++) { diff --git a/guava/src/test/java/com/google/common/cache/FakeTicker.java b/guava/src/test/java/com/google/common/cache/FakeTicker.java deleted file mode 100644 index 95280d6b2c..0000000000 --- a/guava/src/test/java/com/google/common/cache/FakeTicker.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright 2014 Ben Manes. All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.common.cache; - -import java.io.Serializable; - -import com.github.benmanes.caffeine.cache.Ticker; - -/** - * @author ben.manes@gmail.com (Ben Manes) - */ -final class FakeTicker extends com.google.common.testing.FakeTicker - implements Ticker, Serializable { - private static final long serialVersionUID = 1L; -} diff --git a/simulator/build.gradle b/simulator/build.gradle index 09f4ddc067..216fb03b3b 100644 --- a/simulator/build.gradle +++ b/simulator/build.gradle @@ -31,6 +31,10 @@ test { useTestNG() } +coverity { + skip = true +} + tasks.withType(Javadoc) { options.addStringOption('Xdoclint:none', '-quiet') // https://github.com/akka/akka/issues/21165