The following issues were found
guava-testlib/src/com/google/common/testing/CollectorTester.java
15 issues
Line: 69
return new CollectorTester<>(collector, equivalence);
}
private final Collector<T, A, R> collector;
private final BiPredicate<? super R, ? super R> equivalence;
private CollectorTester(
Collector<T, A, R> collector, BiPredicate<? super R, ? super R> equivalence) {
this.collector = checkNotNull(collector);
Reported by PMD.
Line: 70
}
private final Collector<T, A, R> collector;
private final BiPredicate<? super R, ? super R> equivalence;
private CollectorTester(
Collector<T, A, R> collector, BiPredicate<? super R, ? super R> equivalence) {
this.collector = checkNotNull(collector);
this.equivalence = checkNotNull(equivalence);
Reported by PMD.
Line: 87
SEQUENTIAL {
@Override
final <T, A, R> A result(Collector<T, A, R> collector, Iterable<T> inputs) {
A accum = collector.supplier().get();
for (T input : inputs) {
collector.accumulator().accept(accum, input);
}
return accum;
}
Reported by PMD.
Line: 89
final <T, A, R> A result(Collector<T, A, R> collector, Iterable<T> inputs) {
A accum = collector.supplier().get();
for (T input : inputs) {
collector.accumulator().accept(accum, input);
}
return accum;
}
},
/** Get one accumulator for each element and merge the accumulators left-to-right. */
Reported by PMD.
Line: 98
MERGE_LEFT_ASSOCIATIVE {
@Override
final <T, A, R> A result(Collector<T, A, R> collector, Iterable<T> inputs) {
A accum = collector.supplier().get();
for (T input : inputs) {
A newAccum = collector.supplier().get();
collector.accumulator().accept(newAccum, input);
accum = collector.combiner().apply(accum, newAccum);
}
Reported by PMD.
Line: 100
final <T, A, R> A result(Collector<T, A, R> collector, Iterable<T> inputs) {
A accum = collector.supplier().get();
for (T input : inputs) {
A newAccum = collector.supplier().get();
collector.accumulator().accept(newAccum, input);
accum = collector.combiner().apply(accum, newAccum);
}
return accum;
}
Reported by PMD.
Line: 101
A accum = collector.supplier().get();
for (T input : inputs) {
A newAccum = collector.supplier().get();
collector.accumulator().accept(newAccum, input);
accum = collector.combiner().apply(accum, newAccum);
}
return accum;
}
},
Reported by PMD.
Line: 102
for (T input : inputs) {
A newAccum = collector.supplier().get();
collector.accumulator().accept(newAccum, input);
accum = collector.combiner().apply(accum, newAccum);
}
return accum;
}
},
/** Get one accumulator for each element and merge the accumulators right-to-left. */
Reported by PMD.
Line: 113
final <T, A, R> A result(Collector<T, A, R> collector, Iterable<T> inputs) {
List<A> stack = new ArrayList<>();
for (T input : inputs) {
A newAccum = collector.supplier().get();
collector.accumulator().accept(newAccum, input);
push(stack, newAccum);
}
push(stack, collector.supplier().get());
while (stack.size() > 1) {
Reported by PMD.
Line: 114
List<A> stack = new ArrayList<>();
for (T input : inputs) {
A newAccum = collector.supplier().get();
collector.accumulator().accept(newAccum, input);
push(stack, newAccum);
}
push(stack, collector.supplier().get());
while (stack.size() > 1) {
A right = pop(stack);
Reported by PMD.
guava-tests/benchmark/com/google/common/hash/MessageDigestAlgorithmBenchmark.java
15 issues
Line: 42
*/
public class MessageDigestAlgorithmBenchmark {
@Param({"10", "1000", "100000", "1000000"})
int size;
@Param Algorithm algorithm;
@Param HashMethod hashMethod;
private enum HashMethod {
Reported by PMD.
Line: 44
@Param({"10", "1000", "100000", "1000000"})
int size;
@Param Algorithm algorithm;
@Param HashMethod hashMethod;
private enum HashMethod {
MESSAGE_DIGEST_API() {
@Override
Reported by PMD.
Line: 45
int size;
@Param Algorithm algorithm;
@Param HashMethod hashMethod;
private enum HashMethod {
MESSAGE_DIGEST_API() {
@Override
public byte[] hash(Algorithm algorithm, byte[] input) {
Reported by PMD.
Line: 52
@Override
public byte[] hash(Algorithm algorithm, byte[] input) {
MessageDigest md = algorithm.getMessageDigest();
md.update(input);
return md.digest();
}
},
HASH_FUNCTION_DIRECT() {
@Override
Reported by PMD.
Line: 53
public byte[] hash(Algorithm algorithm, byte[] input) {
MessageDigest md = algorithm.getMessageDigest();
md.update(input);
return md.digest();
}
},
HASH_FUNCTION_DIRECT() {
@Override
public byte[] hash(Algorithm algorithm, byte[] input) {
Reported by PMD.
Line: 59
HASH_FUNCTION_DIRECT() {
@Override
public byte[] hash(Algorithm algorithm, byte[] input) {
return algorithm.getHashFunction().hashBytes(input).asBytes();
}
},
HASH_FUNCTION_VIA_HASHER() {
@Override
public byte[] hash(Algorithm algorithm, byte[] input) {
Reported by PMD.
Line: 59
HASH_FUNCTION_DIRECT() {
@Override
public byte[] hash(Algorithm algorithm, byte[] input) {
return algorithm.getHashFunction().hashBytes(input).asBytes();
}
},
HASH_FUNCTION_VIA_HASHER() {
@Override
public byte[] hash(Algorithm algorithm, byte[] input) {
Reported by PMD.
Line: 65
HASH_FUNCTION_VIA_HASHER() {
@Override
public byte[] hash(Algorithm algorithm, byte[] input) {
return algorithm.getHashFunction().newHasher().putBytes(input).hash().asBytes();
}
};
;
public abstract byte[] hash(Algorithm algorithm, byte[] input);
Reported by PMD.
Line: 65
HASH_FUNCTION_VIA_HASHER() {
@Override
public byte[] hash(Algorithm algorithm, byte[] input) {
return algorithm.getHashFunction().newHasher().putBytes(input).hash().asBytes();
}
};
;
public abstract byte[] hash(Algorithm algorithm, byte[] input);
Reported by PMD.
Line: 65
HASH_FUNCTION_VIA_HASHER() {
@Override
public byte[] hash(Algorithm algorithm, byte[] input) {
return algorithm.getHashFunction().newHasher().putBytes(input).hash().asBytes();
}
};
;
public abstract byte[] hash(Algorithm algorithm, byte[] input);
Reported by PMD.
guava-tests/test/com/google/common/collect/SimpleAbstractMultisetTest.java
15 issues
Line: 45
@SuppressWarnings("serial") // No serialization is used in this test
@GwtCompatible(emulated = true)
public class SimpleAbstractMultisetTest extends TestCase {
@GwtIncompatible // suite
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(SimpleAbstractMultisetTest.class);
suite.addTest(
MultisetTestSuiteBuilder.using(
Reported by PMD.
Line: 68
return suite;
}
public void testFastAddAllMultiset() {
final AtomicInteger addCalls = new AtomicInteger();
Multiset<String> multiset =
new NoRemoveMultiset<String>() {
@Override
public int add(String element, int occurrences) {
Reported by PMD.
Line: 81
ImmutableMultiset<String> adds =
new ImmutableMultiset.Builder<String>().addCopies("x", 10).build();
multiset.addAll(adds);
assertEquals(1, addCalls.get());
}
public void testRemoveUnsupported() {
Multiset<String> multiset = new NoRemoveMultiset<>();
multiset.add("a");
Reported by PMD.
Line: 84
assertEquals(1, addCalls.get());
}
public void testRemoveUnsupported() {
Multiset<String> multiset = new NoRemoveMultiset<>();
multiset.add("a");
try {
multiset.remove("a");
fail();
Reported by PMD.
Line: 89
multiset.add("a");
try {
multiset.remove("a");
fail();
} catch (UnsupportedOperationException expected) {
}
assertTrue(multiset.contains("a"));
}
Reported by PMD.
Line: 89
multiset.add("a");
try {
multiset.remove("a");
fail();
} catch (UnsupportedOperationException expected) {
}
assertTrue(multiset.contains("a"));
}
Reported by PMD.
Line: 92
fail();
} catch (UnsupportedOperationException expected) {
}
assertTrue(multiset.contains("a"));
}
private static class NoRemoveMultiset<E> extends AbstractMultiset<E> implements Serializable {
final Map<E, Integer> backingMap = Maps.newHashMap();
Reported by PMD.
Line: 140
@Override
Iterator<Entry<E>> entryIterator() {
final Iterator<Map.Entry<E, Integer>> backingEntries = backingMap.entrySet().iterator();
return new UnmodifiableIterator<Multiset.Entry<E>>() {
@Override
public boolean hasNext() {
return backingEntries.hasNext();
}
Reported by PMD.
Line: 70
public void testFastAddAllMultiset() {
final AtomicInteger addCalls = new AtomicInteger();
Multiset<String> multiset =
new NoRemoveMultiset<String>() {
@Override
public int add(String element, int occurrences) {
addCalls.incrementAndGet();
return super.add(element, occurrences);
Reported by PMD.
Line: 70
public void testFastAddAllMultiset() {
final AtomicInteger addCalls = new AtomicInteger();
Multiset<String> multiset =
new NoRemoveMultiset<String>() {
@Override
public int add(String element, int occurrences) {
addCalls.incrementAndGet();
return super.add(element, occurrences);
Reported by PMD.
guava-tests/benchmark/com/google/common/collect/SortedCopyBenchmark.java
15 issues
Line: 38
*/
public class SortedCopyBenchmark {
@Param({"1", "10", "1000", "1000000"})
int size; // logarithmic triangular
@Param boolean mutable;
@Param InputOrder inputOrder;
Reported by PMD.
Line: 40
@Param({"1", "10", "1000", "1000000"})
int size; // logarithmic triangular
@Param boolean mutable;
@Param InputOrder inputOrder;
enum InputOrder {
SORTED {
Reported by PMD.
Line: 42
@Param boolean mutable;
@Param InputOrder inputOrder;
enum InputOrder {
SORTED {
@Override
void arrange(List<Integer> list) {
Reported by PMD.
Line: 55
@Override
void arrange(List<Integer> list) {
Collections.sort(list);
if (list.size() > 1) {
int i = (list.size() - 1) / 2;
Collections.swap(list, i, i + 1);
}
}
},
Reported by PMD.
Line: 69
abstract void arrange(List<Integer> list);
}
private ImmutableList<Integer> input;
@BeforeExperiment
void setUp() {
checkArgument(size > 0, "empty collection not supported");
Set<Integer> set = new LinkedHashSet<>(size);
Reported by PMD.
Line: 71
private ImmutableList<Integer> input;
@BeforeExperiment
void setUp() {
checkArgument(size > 0, "empty collection not supported");
Set<Integer> set = new LinkedHashSet<>(size);
Random random = new Random();
Reported by PMD.
Line: 91
// Yes, this could be done more elegantly
if (mutable) {
for (int i = 0; i < reps; i++) {
List<Integer> copy = new ArrayList<>(input);
Collections.sort(copy);
dummy += copy.get(0);
}
} else {
for (int i = 0; i < reps; i++) {
Reported by PMD.
Line: 97
}
} else {
for (int i = 0; i < reps; i++) {
List<Integer> copy = new ArrayList<>(input);
Collections.sort(copy);
dummy += ImmutableList.copyOf(copy).get(0);
}
}
return dummy;
Reported by PMD.
Line: 99
for (int i = 0; i < reps; i++) {
List<Integer> copy = new ArrayList<>(input);
Collections.sort(copy);
dummy += ImmutableList.copyOf(copy).get(0);
}
}
return dummy;
}
Reported by PMD.
Line: 110
int dummy = 0;
if (mutable) {
for (int i = 0; i < reps; i++) {
dummy += ORDERING.sortedCopy(input).get(0);
}
} else {
for (int i = 0; i < reps; i++) {
dummy += ORDERING.immutableSortedCopy(input).get(0);
}
Reported by PMD.
guava-tests/benchmark/com/google/common/math/StatsBenchmark.java
15 issues
Line: 73
}
static class MeanAndVariance {
private final double mean;
private final double variance;
MeanAndVariance(double mean, double variance) {
this.mean = mean;
this.variance = variance;
Reported by PMD.
Line: 74
static class MeanAndVariance {
private final double mean;
private final double variance;
MeanAndVariance(double mean, double variance) {
this.mean = mean;
this.variance = variance;
}
Reported by PMD.
Line: 82
}
@Override
public int hashCode() {
return Doubles.hashCode(mean) * 31 + Doubles.hashCode(variance);
}
}
enum VarianceAlgorithm {
Reported by PMD.
Line: 144
}
@Param({"100", "10000"})
int n;
@Param MeanAlgorithm meanAlgorithm;
@Param VarianceAlgorithm varianceAlgorithm;
private double[][] values = new double[0x100][];
Reported by PMD.
Line: 146
@Param({"100", "10000"})
int n;
@Param MeanAlgorithm meanAlgorithm;
@Param VarianceAlgorithm varianceAlgorithm;
private double[][] values = new double[0x100][];
@BeforeExperiment
Reported by PMD.
Line: 147
int n;
@Param MeanAlgorithm meanAlgorithm;
@Param VarianceAlgorithm varianceAlgorithm;
private double[][] values = new double[0x100][];
@BeforeExperiment
void setUp() {
Reported by PMD.
Line: 149
@Param MeanAlgorithm meanAlgorithm;
@Param VarianceAlgorithm varianceAlgorithm;
private double[][] values = new double[0x100][];
@BeforeExperiment
void setUp() {
Random rng = new Random();
for (int i = 0; i < 0x100; i++) {
Reported by PMD.
Line: 151
private double[][] values = new double[0x100][];
@BeforeExperiment
void setUp() {
Random rng = new Random();
for (int i = 0; i < 0x100; i++) {
values[i] = new double[n];
for (int j = 0; j < n; j++) {
Reported by PMD.
Line: 166
int meanAndVariance(int reps) {
int tmp = 0;
for (int i = 0; i < reps; i++) {
tmp += varianceAlgorithm.variance(values[i & 0xFF], meanAlgorithm).hashCode();
}
return tmp;
}
}
Reported by PMD.
Line: 69
}
};
abstract double mean(double[] values);
}
static class MeanAndVariance {
private final double mean;
private final double variance;
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/google/MultisetIteratorTester.java
15 issues
Line: 42
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetIteratorTester<E> extends AbstractMultisetTester<E> {
@SuppressWarnings("unchecked")
@CollectionFeature.Require({SUPPORTS_ITERATOR_REMOVE, KNOWN_ORDER})
public void testRemovingIteratorKnownOrder() {
new IteratorTester<E>(
4,
MODIFIABLE,
Reported by PMD.
Line: 42
@GwtCompatible(emulated = true)
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MultisetIteratorTester<E> extends AbstractMultisetTester<E> {
@SuppressWarnings("unchecked")
@CollectionFeature.Require({SUPPORTS_ITERATOR_REMOVE, KNOWN_ORDER})
public void testRemovingIteratorKnownOrder() {
new IteratorTester<E>(
4,
MODIFIABLE,
Reported by PMD.
Line: 48
new IteratorTester<E>(
4,
MODIFIABLE,
getSubjectGenerator().order(Arrays.asList(e0(), e1(), e1(), e2())),
IteratorTester.KnownOrder.KNOWN_ORDER) {
@Override
protected Iterator<E> newTargetIterator() {
return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
}
Reported by PMD.
Line: 52
IteratorTester.KnownOrder.KNOWN_ORDER) {
@Override
protected Iterator<E> newTargetIterator() {
return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
}
}.test();
}
@SuppressWarnings("unchecked")
Reported by PMD.
Line: 52
IteratorTester.KnownOrder.KNOWN_ORDER) {
@Override
protected Iterator<E> newTargetIterator() {
return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
}
}.test();
}
@SuppressWarnings("unchecked")
Reported by PMD.
Line: 57
}.test();
}
@SuppressWarnings("unchecked")
@CollectionFeature.Require(value = SUPPORTS_ITERATOR_REMOVE, absent = KNOWN_ORDER)
public void testRemovingIteratorUnknownOrder() {
new IteratorTester<E>(
4,
MODIFIABLE,
Reported by PMD.
Line: 67
IteratorTester.KnownOrder.UNKNOWN_ORDER) {
@Override
protected Iterator<E> newTargetIterator() {
return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
}
}.test();
}
@SuppressWarnings("unchecked")
Reported by PMD.
Line: 67
IteratorTester.KnownOrder.UNKNOWN_ORDER) {
@Override
protected Iterator<E> newTargetIterator() {
return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
}
}.test();
}
@SuppressWarnings("unchecked")
Reported by PMD.
Line: 72
}.test();
}
@SuppressWarnings("unchecked")
@CollectionFeature.Require(value = KNOWN_ORDER, absent = SUPPORTS_ITERATOR_REMOVE)
public void testIteratorKnownOrder() {
new IteratorTester<E>(
4,
UNMODIFIABLE,
Reported by PMD.
Line: 78
new IteratorTester<E>(
4,
UNMODIFIABLE,
getSubjectGenerator().order(Arrays.asList(e0(), e1(), e1(), e2())),
IteratorTester.KnownOrder.KNOWN_ORDER) {
@Override
protected Iterator<E> newTargetIterator() {
return getSubjectGenerator().create(e0(), e1(), e1(), e2()).iterator();
}
Reported by PMD.
android/guava/src/com/google/common/collect/ImmutableListMultimap.java
15 issues
Line: 50
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public class ImmutableListMultimap<K, V> extends ImmutableMultimap<K, V>
implements ListMultimap<K, V> {
/**
* Returns the empty multimap.
*
* <p><b>Performance note:</b> the instance returned is a singleton.
Reported by PMD.
Line: 99
}
/** Returns an immutable multimap containing the given entries, in order. */
public static <K, V> ImmutableListMultimap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
ImmutableListMultimap.Builder<K, V> builder = ImmutableListMultimap.builder();
builder.put(k1, v1);
builder.put(k2, v2);
builder.put(k3, v3);
Reported by PMD.
Line: 258
if (multimap instanceof ImmutableListMultimap) {
@SuppressWarnings("unchecked") // safe since multimap is not writable
ImmutableListMultimap<K, V> kvMultimap = (ImmutableListMultimap<K, V>) multimap;
if (!kvMultimap.isPartialView()) {
return kvMultimap;
}
}
return fromMapEntries(multimap.asMap().entrySet(), null);
Reported by PMD.
Line: 263
}
}
return fromMapEntries(multimap.asMap().entrySet(), null);
}
/**
* Returns an immutable multimap containing the specified entries. The returned multimap iterates
* over keys in the order they were first encountered in the input, and the values for each key
Reported by PMD.
Line: 298
(valueComparator == null)
? ImmutableList.copyOf(values)
: ImmutableList.sortedCopyOf(valueComparator, values);
if (!list.isEmpty()) {
builder.put(key, list);
size += list.size();
}
}
Reported by PMD.
Line: 300
: ImmutableList.sortedCopyOf(valueComparator, values);
if (!list.isEmpty()) {
builder.put(key, list);
size += list.size();
}
}
return new ImmutableListMultimap<>(builder.build(), size);
}
Reported by PMD.
Line: 325
return (list == null) ? ImmutableList.<V>of() : list;
}
@LazyInit @RetainedWith @CheckForNull private transient ImmutableListMultimap<V, K> inverse;
/**
* {@inheritDoc}
*
* <p>Because an inverse of a list multimap can contain multiple pairs with the same key and
Reported by PMD.
Line: 422
throw (InvalidObjectException) new InvalidObjectException(e.getMessage()).initCause(e);
}
FieldSettersHolder.MAP_FIELD_SETTER.set(this, tmpMap);
FieldSettersHolder.SIZE_FIELD_SETTER.set(this, tmpSize);
}
@GwtIncompatible // Not needed in emulated source
private static final long serialVersionUID = 0;
Reported by PMD.
Line: 423
}
FieldSettersHolder.MAP_FIELD_SETTER.set(this, tmpMap);
FieldSettersHolder.SIZE_FIELD_SETTER.set(this, tmpSize);
}
@GwtIncompatible // Not needed in emulated source
private static final long serialVersionUID = 0;
}
Reported by PMD.
Line: 292
int size = 0;
for (Entry<? extends K, ? extends Collection<? extends V>> entry : mapEntries) {
K key = entry.getKey();
Collection<? extends V> values = entry.getValue();
ImmutableList<V> list =
(valueComparator == null)
? ImmutableList.copyOf(values)
: ImmutableList.sortedCopyOf(valueComparator, values);
Reported by PMD.
android/guava/src/com/google/common/eventbus/EventBus.java
15 issues
Line: 153
private static final Logger logger = Logger.getLogger(EventBus.class.getName());
private final String identifier;
private final Executor executor;
private final SubscriberExceptionHandler exceptionHandler;
private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
private final Dispatcher dispatcher;
Reported by PMD.
Line: 153
private static final Logger logger = Logger.getLogger(EventBus.class.getName());
private final String identifier;
private final Executor executor;
private final SubscriberExceptionHandler exceptionHandler;
private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
private final Dispatcher dispatcher;
Reported by PMD.
Line: 154
private static final Logger logger = Logger.getLogger(EventBus.class.getName());
private final String identifier;
private final Executor executor;
private final SubscriberExceptionHandler exceptionHandler;
private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
private final Dispatcher dispatcher;
Reported by PMD.
Line: 154
private static final Logger logger = Logger.getLogger(EventBus.class.getName());
private final String identifier;
private final Executor executor;
private final SubscriberExceptionHandler exceptionHandler;
private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
private final Dispatcher dispatcher;
Reported by PMD.
Line: 155
private final String identifier;
private final Executor executor;
private final SubscriberExceptionHandler exceptionHandler;
private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
private final Dispatcher dispatcher;
/** Creates a new EventBus named "default". */
Reported by PMD.
Line: 157
private final Executor executor;
private final SubscriberExceptionHandler exceptionHandler;
private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
private final Dispatcher dispatcher;
/** Creates a new EventBus named "default". */
public EventBus() {
this("default");
Reported by PMD.
Line: 158
private final SubscriberExceptionHandler exceptionHandler;
private final SubscriberRegistry subscribers = new SubscriberRegistry(this);
private final Dispatcher dispatcher;
/** Creates a new EventBus named "default". */
public EventBus() {
this("default");
}
Reported by PMD.
Line: 224
checkNotNull(context);
try {
exceptionHandler.handleException(e, context);
} catch (Throwable e2) {
// if the handler threw an exception... well, just log it
logger.log(
Level.SEVERE,
String.format(Locale.ROOT, "Exception %s thrown while handling exception: %s", e2, e),
e2);
Reported by PMD.
Line: 274
@Override
public String toString() {
return MoreObjects.toStringHelper(this).addValue(identifier).toString();
}
/** Simple logging handler for subscriber exceptions. */
static final class LoggingHandler implements SubscriberExceptionHandler {
static final LoggingHandler INSTANCE = new LoggingHandler();
Reported by PMD.
Line: 274
@Override
public String toString() {
return MoreObjects.toStringHelper(this).addValue(identifier).toString();
}
/** Simple logging handler for subscriber exceptions. */
static final class LoggingHandler implements SubscriberExceptionHandler {
static final LoggingHandler INSTANCE = new LoggingHandler();
Reported by PMD.
android/guava/src/com/google/common/cache/AbstractCache.java
15 issues
Line: 169
* @param loadTime the number of nanoseconds the cache spent computing or retrieving the new
* value
*/
@SuppressWarnings("GoodTime") // should accept a java.time.Duration
void recordLoadSuccess(long loadTime);
/**
* Records the failed load of a new entry. This should be called when a cache request causes an
* entry to be loaded, but an exception is thrown while loading the entry. In contrast to {@link
Reported by PMD.
Line: 203
* @since 10.0
*/
public static final class SimpleStatsCounter implements StatsCounter {
private final LongAddable hitCount = LongAddables.create();
private final LongAddable missCount = LongAddables.create();
private final LongAddable loadSuccessCount = LongAddables.create();
private final LongAddable loadExceptionCount = LongAddables.create();
private final LongAddable totalLoadTime = LongAddables.create();
private final LongAddable evictionCount = LongAddables.create();
Reported by PMD.
Line: 204
*/
public static final class SimpleStatsCounter implements StatsCounter {
private final LongAddable hitCount = LongAddables.create();
private final LongAddable missCount = LongAddables.create();
private final LongAddable loadSuccessCount = LongAddables.create();
private final LongAddable loadExceptionCount = LongAddables.create();
private final LongAddable totalLoadTime = LongAddables.create();
private final LongAddable evictionCount = LongAddables.create();
Reported by PMD.
Line: 205
public static final class SimpleStatsCounter implements StatsCounter {
private final LongAddable hitCount = LongAddables.create();
private final LongAddable missCount = LongAddables.create();
private final LongAddable loadSuccessCount = LongAddables.create();
private final LongAddable loadExceptionCount = LongAddables.create();
private final LongAddable totalLoadTime = LongAddables.create();
private final LongAddable evictionCount = LongAddables.create();
/** Constructs an instance with all counts initialized to zero. */
Reported by PMD.
Line: 206
private final LongAddable hitCount = LongAddables.create();
private final LongAddable missCount = LongAddables.create();
private final LongAddable loadSuccessCount = LongAddables.create();
private final LongAddable loadExceptionCount = LongAddables.create();
private final LongAddable totalLoadTime = LongAddables.create();
private final LongAddable evictionCount = LongAddables.create();
/** Constructs an instance with all counts initialized to zero. */
public SimpleStatsCounter() {}
Reported by PMD.
Line: 207
private final LongAddable missCount = LongAddables.create();
private final LongAddable loadSuccessCount = LongAddables.create();
private final LongAddable loadExceptionCount = LongAddables.create();
private final LongAddable totalLoadTime = LongAddables.create();
private final LongAddable evictionCount = LongAddables.create();
/** Constructs an instance with all counts initialized to zero. */
public SimpleStatsCounter() {}
Reported by PMD.
Line: 208
private final LongAddable loadSuccessCount = LongAddables.create();
private final LongAddable loadExceptionCount = LongAddables.create();
private final LongAddable totalLoadTime = LongAddables.create();
private final LongAddable evictionCount = LongAddables.create();
/** Constructs an instance with all counts initialized to zero. */
public SimpleStatsCounter() {}
/** @since 11.0 */
Reported by PMD.
Line: 263
/** Increments all counters by the values in {@code other}. */
public void incrementBy(StatsCounter other) {
CacheStats otherStats = other.snapshot();
hitCount.add(otherStats.hitCount());
missCount.add(otherStats.missCount());
loadSuccessCount.add(otherStats.loadSuccessCount());
loadExceptionCount.add(otherStats.loadExceptionCount());
totalLoadTime.add(otherStats.totalLoadTime());
evictionCount.add(otherStats.evictionCount());
Reported by PMD.
Line: 264
public void incrementBy(StatsCounter other) {
CacheStats otherStats = other.snapshot();
hitCount.add(otherStats.hitCount());
missCount.add(otherStats.missCount());
loadSuccessCount.add(otherStats.loadSuccessCount());
loadExceptionCount.add(otherStats.loadExceptionCount());
totalLoadTime.add(otherStats.totalLoadTime());
evictionCount.add(otherStats.evictionCount());
}
Reported by PMD.
Line: 265
CacheStats otherStats = other.snapshot();
hitCount.add(otherStats.hitCount());
missCount.add(otherStats.missCount());
loadSuccessCount.add(otherStats.loadSuccessCount());
loadExceptionCount.add(otherStats.loadExceptionCount());
totalLoadTime.add(otherStats.totalLoadTime());
evictionCount.add(otherStats.evictionCount());
}
}
Reported by PMD.
android/guava/src/com/google/common/collect/ForwardingMultiset.java
15 issues
Line: 54
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingMultiset<E extends @Nullable Object> extends ForwardingCollection<E>
implements Multiset<E> {
/** Constructor for use by subclasses. */
protected ForwardingMultiset() {}
@Override
Reported by PMD.
Line: 64
@Override
public int count(@CheckForNull Object element) {
return delegate().count(element);
}
@CanIgnoreReturnValue
@Override
public int add(@ParametricNullness E element, int occurrences) {
Reported by PMD.
Line: 70
@CanIgnoreReturnValue
@Override
public int add(@ParametricNullness E element, int occurrences) {
return delegate().add(element, occurrences);
}
@CanIgnoreReturnValue
@Override
public int remove(@CheckForNull Object element, int occurrences) {
Reported by PMD.
Line: 76
@CanIgnoreReturnValue
@Override
public int remove(@CheckForNull Object element, int occurrences) {
return delegate().remove(element, occurrences);
}
@Override
public Set<E> elementSet() {
return delegate().elementSet();
Reported by PMD.
Line: 81
@Override
public Set<E> elementSet() {
return delegate().elementSet();
}
@Override
public Set<Entry<E>> entrySet() {
return delegate().entrySet();
Reported by PMD.
Line: 86
@Override
public Set<Entry<E>> entrySet() {
return delegate().entrySet();
}
@Override
public boolean equals(@CheckForNull Object object) {
return object == this || delegate().equals(object);
Reported by PMD.
Line: 91
@Override
public boolean equals(@CheckForNull Object object) {
return object == this || delegate().equals(object);
}
@Override
public int hashCode() {
return delegate().hashCode();
Reported by PMD.
Line: 96
@Override
public int hashCode() {
return delegate().hashCode();
}
@CanIgnoreReturnValue
@Override
public int setCount(@ParametricNullness E element, int count) {
Reported by PMD.
Line: 102
@CanIgnoreReturnValue
@Override
public int setCount(@ParametricNullness E element, int count) {
return delegate().setCount(element, count);
}
@CanIgnoreReturnValue
@Override
public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {
Reported by PMD.
Line: 108
@CanIgnoreReturnValue
@Override
public boolean setCount(@ParametricNullness E element, int oldCount, int newCount) {
return delegate().setCount(element, oldCount, newCount);
}
/**
* A sensible definition of {@link #contains} in terms of {@link #count}. If you override {@link
* #count}, you may wish to override {@link #contains} to forward to this implementation.
Reported by PMD.