The following issues were found
guava-tests/test/com/google/common/collect/ImmutableRangeMapTest.java
95 issues
Line: 32
* @author Louis Wasserman
*/
@GwtIncompatible // NavigableMap
public class ImmutableRangeMapTest extends TestCase {
private static final ImmutableList<Range<Integer>> RANGES;
private static final int MIN_BOUND = 0;
private static final int MAX_BOUND = 10;
static {
Reported by PMD.
Line: 66
RANGES = builder.build();
}
public void testBuilderRejectsEmptyRanges() {
for (int i = MIN_BOUND; i <= MAX_BOUND; i++) {
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
try {
builder.put(Range.closedOpen(i, i), 1);
fail("Expected IllegalArgumentException");
Reported by PMD.
Line: 71
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
try {
builder.put(Range.closedOpen(i, i), 1);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
// success
}
try {
builder.put(Range.openClosed(i, i), 1);
Reported by PMD.
Line: 77
}
try {
builder.put(Range.openClosed(i, i), 1);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
}
}
Reported by PMD.
Line: 83
}
}
public void testOverlapRejection() {
for (Range<Integer> range1 : RANGES) {
for (Range<Integer> range2 : RANGES) {
boolean expectRejection =
range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
Reported by PMD.
Line: 83
}
}
public void testOverlapRejection() {
for (Range<Integer> range1 : RANGES) {
for (Range<Integer> range2 : RANGES) {
boolean expectRejection =
range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
Reported by PMD.
Line: 87
for (Range<Integer> range1 : RANGES) {
for (Range<Integer> range2 : RANGES) {
boolean expectRejection =
range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
builder.put(range1, 1).put(range2, 2);
try {
ImmutableRangeMap<Integer, Integer> unused = builder.build();
assertFalse(expectRejection);
Reported by PMD.
Line: 89
boolean expectRejection =
range1.isConnected(range2) && !range1.intersection(range2).isEmpty();
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
builder.put(range1, 1).put(range2, 2);
try {
ImmutableRangeMap<Integer, Integer> unused = builder.build();
assertFalse(expectRejection);
} catch (IllegalArgumentException e) {
assertTrue(expectRejection);
Reported by PMD.
Line: 91
ImmutableRangeMap.Builder<Integer, Integer> builder = ImmutableRangeMap.builder();
builder.put(range1, 1).put(range2, 2);
try {
ImmutableRangeMap<Integer, Integer> unused = builder.build();
assertFalse(expectRejection);
} catch (IllegalArgumentException e) {
assertTrue(expectRejection);
}
}
Reported by PMD.
Line: 92
builder.put(range1, 1).put(range2, 2);
try {
ImmutableRangeMap<Integer, Integer> unused = builder.build();
assertFalse(expectRejection);
} catch (IllegalArgumentException e) {
assertTrue(expectRejection);
}
}
}
Reported by PMD.
guava-tests/test/com/google/common/base/EnumsTest.java
92 issues
Line: 48
* @author Steve McKay
*/
@GwtCompatible(emulated = true)
public class EnumsTest extends TestCase {
private enum TestEnum {
CHEETO,
HONDA,
POODLE,
Reported by PMD.
Line: 58
private enum OtherEnum {}
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
Reported by PMD.
Line: 58
private enum OtherEnum {}
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
Reported by PMD.
Line: 59
private enum OtherEnum {}
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
Reported by PMD.
Line: 59
private enum OtherEnum {}
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
Reported by PMD.
Line: 60
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).isPresent();
Reported by PMD.
Line: 60
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).isPresent();
Reported by PMD.
Line: 61
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).isPresent();
Reported by PMD.
Line: 61
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).isPresent();
Reported by PMD.
Line: 63
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
Reported by PMD.
android/guava-tests/test/com/google/common/base/EnumsTest.java
92 issues
Line: 48
* @author Steve McKay
*/
@GwtCompatible(emulated = true)
public class EnumsTest extends TestCase {
private enum TestEnum {
CHEETO,
HONDA,
POODLE,
Reported by PMD.
Line: 58
private enum OtherEnum {}
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
Reported by PMD.
Line: 58
private enum OtherEnum {}
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
Reported by PMD.
Line: 59
private enum OtherEnum {}
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
Reported by PMD.
Line: 59
private enum OtherEnum {}
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
Reported by PMD.
Line: 60
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).isPresent();
Reported by PMD.
Line: 60
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).isPresent();
Reported by PMD.
Line: 61
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).isPresent();
Reported by PMD.
Line: 61
public void testGetIfPresent() {
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).isPresent();
Reported by PMD.
Line: 63
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).hasValue(TestEnum.POODLE);
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "POODLE")).isPresent();
assertThat(Enums.getIfPresent(TestEnum.class, "CHEETO")).hasValue(TestEnum.CHEETO);
assertThat(Enums.getIfPresent(TestEnum.class, "HONDA")).hasValue(TestEnum.HONDA);
Reported by PMD.
android/guava/src/com/google/common/collect/TreeMultiset.java
91 issues
Line: 61
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class TreeMultiset<E extends @Nullable Object> extends AbstractSortedMultiset<E>
implements Serializable {
/**
* Creates a new, empty multiset, sorted according to the elements' natural order. All elements
* inserted into the multiset must implement the {@code Comparable} interface. Furthermore, all
Reported by PMD.
Line: 61
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class TreeMultiset<E extends @Nullable Object> extends AbstractSortedMultiset<E>
implements Serializable {
/**
* Creates a new, empty multiset, sorted according to the elements' natural order. All elements
* inserted into the multiset must implement the {@code Comparable} interface. Furthermore, all
Reported by PMD.
Line: 62
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class TreeMultiset<E extends @Nullable Object> extends AbstractSortedMultiset<E>
implements Serializable {
/**
* Creates a new, empty multiset, sorted according to the elements' natural order. All elements
* inserted into the multiset must implement the {@code Comparable} interface. Furthermore, all
* such elements must be <i>mutually comparable</i>: {@code e1.compareTo(e2)} must not throw a
Reported by PMD.
Line: 91
* @param comparator the comparator that will be used to sort this multiset. A null value
* indicates that the elements' <i>natural ordering</i> should be used.
*/
@SuppressWarnings("unchecked")
public static <E extends @Nullable Object> TreeMultiset<E> create(
@CheckForNull Comparator<? super E> comparator) {
return (comparator == null)
? new TreeMultiset<E>((Comparator) Ordering.natural())
: new TreeMultiset<E>(comparator);
Reported by PMD.
Line: 181
}
// The cast is safe because we call this method only if hasLowerBound().
int cmp =
comparator()
.compare(uncheckedCastNullableTToT(range.getLowerEndpoint()), node.getElement());
if (cmp < 0) {
return aggregateBelowRange(aggr, node.left);
} else if (cmp == 0) {
switch (range.getLowerBoundType()) {
Reported by PMD.
Line: 207
}
// The cast is safe because we call this method only if hasUpperBound().
int cmp =
comparator()
.compare(uncheckedCastNullableTToT(range.getUpperEndpoint()), node.getElement());
if (cmp > 0) {
return aggregateAboveRange(aggr, node.right);
} else if (cmp == 0) {
switch (range.getUpperBoundType()) {
Reported by PMD.
Line: 250
if (!range.contains(e) || root == null) {
return 0;
}
return root.count(comparator(), e);
} catch (ClassCastException | NullPointerException e) {
return 0;
}
}
Reported by PMD.
Line: 251
return 0;
}
return root.count(comparator(), e);
} catch (ClassCastException | NullPointerException e) {
return 0;
}
}
@CanIgnoreReturnValue
Reported by PMD.
Line: 251
return 0;
}
return root.count(comparator(), e);
} catch (ClassCastException | NullPointerException e) {
return 0;
}
}
@CanIgnoreReturnValue
Reported by PMD.
Line: 266
checkArgument(range.contains(element));
AvlNode<E> root = rootReference.get();
if (root == null) {
comparator().compare(element, element);
AvlNode<E> newRoot = new AvlNode<E>(element, occurrences);
successor(header, newRoot, header);
rootReference.checkAndSet(root, newRoot);
return 0;
}
Reported by PMD.
android/guava/src/com/google/common/collect/CompactHashMap.java
90 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.collect.CollectPreconditions.checkRemove;
import static com.google.common.collect.CompactHashing.UNSET;
import static com.google.common.collect.Hashing.smearedHash;
import static com.google.common.collect.NullnessCasts.uncheckedCastNullableTToT;
Reported by PMD.
Line: 80
*/
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMap<K, V> implements Serializable {
/*
* TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
* world. Figure out what sort of space-time tradeoff we're actually going to get here with the
* *Map variants. This class is particularly hard to benchmark, because the benefit is not only in
Reported by PMD.
Line: 80
*/
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMap<K, V> implements Serializable {
/*
* TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
* world. Figure out what sort of space-time tradeoff we're actually going to get here with the
* *Map variants. This class is particularly hard to benchmark, because the benefit is not only in
Reported by PMD.
Line: 80
*/
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMap<K, V> implements Serializable {
/*
* TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
* world. Figure out what sort of space-time tradeoff we're actually going to get here with the
* *Map variants. This class is particularly hard to benchmark, because the benefit is not only in
Reported by PMD.
Line: 80
*/
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMap<K, V> implements Serializable {
/*
* TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
* world. Figure out what sort of space-time tradeoff we're actually going to get here with the
* *Map variants. This class is particularly hard to benchmark, because the benefit is not only in
Reported by PMD.
Line: 81
@GwtIncompatible // not worth using in GWT for now
@ElementTypesAreNonnullByDefault
class CompactHashMap<K extends @Nullable Object, V extends @Nullable Object>
extends AbstractMap<K, V> implements Serializable {
/*
* TODO: Make this a drop-in replacement for j.u. versions, actually drop them in, and test the
* world. Figure out what sort of space-time tradeoff we're actually going to get here with the
* *Map variants. This class is particularly hard to benchmark, because the benefit is not only in
* less allocation, but also having the GC do less work to scan the heap because of fewer
Reported by PMD.
Line: 214
* The values of the entries in the map, in the range of [0, size()). The values in [size(),
* values.length) are all {@code null}.
*/
@VisibleForTesting @CheckForNull transient @Nullable Object[] values;
/**
* Keeps track of metadata like the number of hash table bits and modifications of this data
* structure (to make it possible to throw ConcurrentModificationException in the iterator). Note
* that we choose not to make this volatile, so we do less of a "best effort" to track such
Reported by PMD.
Line: 231
private transient int metadata;
/** The number of elements contained in the set. */
private transient int size;
/** Constructs a new empty instance of {@code CompactHashMap}. */
CompactHashMap() {
init(CompactHashing.DEFAULT_SIZE);
}
Reported by PMD.
Line: 278
return expectedSize;
}
@SuppressWarnings("unchecked")
@VisibleForTesting
@CheckForNull
Map<K, V> delegateOrNull() {
if (table instanceof Map) {
return (Map<K, V>) table;
Reported by PMD.
Line: 300
newDelegate.put(key(i), value(i));
}
this.table = newDelegate;
this.entries = null;
this.keys = null;
this.values = null;
incrementModCount();
return newDelegate;
}
Reported by PMD.
guava-tests/test/com/google/common/collect/SynchronizedNavigableMapTest.java
90 issues
Line: 263
suite.addTest(
NavigableMapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
private final Object mutex = new Integer(1);
@Override
protected SortedMap<String, String> create(Entry<String, String>[] entries) {
NavigableMap<String, String> innermost = new SafeTreeMap<>();
for (Entry<String, String> entry : entries) {
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import com.google.common.collect.Synchronized.SynchronizedNavigableMap;
import com.google.common.collect.Synchronized.SynchronizedNavigableSet;
import com.google.common.collect.Synchronized.SynchronizedSortedMap;
import com.google.common.collect.testing.NavigableMapTestSuiteBuilder;
Reported by PMD.
Line: 42
*
* @author Louis Wasserman
*/
public class SynchronizedNavigableMapTest extends SynchronizedMapTest {
@Override
protected <K, V> NavigableMap<K, V> create() {
@SuppressWarnings("unchecked")
NavigableMap<K, V> innermost =
new SafeTreeMap<>((Comparator<? super K>) Ordering.natural().nullsFirst());
Reported by PMD.
Line: 47
protected <K, V> NavigableMap<K, V> create() {
@SuppressWarnings("unchecked")
NavigableMap<K, V> innermost =
new SafeTreeMap<>((Comparator<? super K>) Ordering.natural().nullsFirst());
TestMap<K, V> inner = new TestMap<>(innermost, mutex);
NavigableMap<K, V> outer = Synchronized.navigableMap(inner, mutex);
return outer;
}
Reported by PMD.
Line: 54
}
static class TestEntry<K, V> extends ForwardingMapEntry<K, V> implements Serializable {
private final Entry<K, V> delegate;
private final Object mutex;
TestEntry(Entry<K, V> delegate, Object mutex) {
this.delegate = delegate;
this.mutex = mutex;
Reported by PMD.
Line: 54
}
static class TestEntry<K, V> extends ForwardingMapEntry<K, V> implements Serializable {
private final Entry<K, V> delegate;
private final Object mutex;
TestEntry(Entry<K, V> delegate, Object mutex) {
this.delegate = delegate;
this.mutex = mutex;
Reported by PMD.
Line: 55
static class TestEntry<K, V> extends ForwardingMapEntry<K, V> implements Serializable {
private final Entry<K, V> delegate;
private final Object mutex;
TestEntry(Entry<K, V> delegate, Object mutex) {
this.delegate = delegate;
this.mutex = mutex;
}
Reported by PMD.
Line: 101
}
static class TestMap<K, V> extends SynchronizedMapTest.TestMap<K, V>
implements NavigableMap<K, V> {
public TestMap(NavigableMap<K, V> delegate, Object mutex) {
super(delegate, mutex);
}
Reported by PMD.
Line: 115
@Override
public Entry<K, V> ceilingEntry(K key) {
assertTrue(Thread.holdsLock(mutex));
return delegate().ceilingEntry(key);
}
@Override
public K ceilingKey(K key) {
assertTrue(Thread.holdsLock(mutex));
Reported by PMD.
Line: 121
@Override
public K ceilingKey(K key) {
assertTrue(Thread.holdsLock(mutex));
return delegate().ceilingKey(key);
}
@Override
public NavigableSet<K> descendingKeySet() {
assertTrue(Thread.holdsLock(mutex));
Reported by PMD.
android/guava-tests/test/com/google/common/collect/SynchronizedNavigableMapTest.java
90 issues
Line: 263
suite.addTest(
NavigableMapTestSuiteBuilder.using(
new TestStringSortedMapGenerator() {
private final Object mutex = new Integer(1);
@Override
protected SortedMap<String, String> create(Entry<String, String>[] entries) {
NavigableMap<String, String> innermost = new SafeTreeMap<>();
for (Entry<String, String> entry : entries) {
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import com.google.common.collect.Synchronized.SynchronizedNavigableMap;
import com.google.common.collect.Synchronized.SynchronizedNavigableSet;
import com.google.common.collect.Synchronized.SynchronizedSortedMap;
import com.google.common.collect.testing.NavigableMapTestSuiteBuilder;
Reported by PMD.
Line: 42
*
* @author Louis Wasserman
*/
public class SynchronizedNavigableMapTest extends SynchronizedMapTest {
@Override
protected <K, V> NavigableMap<K, V> create() {
@SuppressWarnings("unchecked")
NavigableMap<K, V> innermost =
new SafeTreeMap<>((Comparator<? super K>) Ordering.natural().nullsFirst());
Reported by PMD.
Line: 47
protected <K, V> NavigableMap<K, V> create() {
@SuppressWarnings("unchecked")
NavigableMap<K, V> innermost =
new SafeTreeMap<>((Comparator<? super K>) Ordering.natural().nullsFirst());
TestMap<K, V> inner = new TestMap<>(innermost, mutex);
NavigableMap<K, V> outer = Synchronized.navigableMap(inner, mutex);
return outer;
}
Reported by PMD.
Line: 54
}
static class TestEntry<K, V> extends ForwardingMapEntry<K, V> implements Serializable {
private final Entry<K, V> delegate;
private final Object mutex;
TestEntry(Entry<K, V> delegate, Object mutex) {
this.delegate = delegate;
this.mutex = mutex;
Reported by PMD.
Line: 54
}
static class TestEntry<K, V> extends ForwardingMapEntry<K, V> implements Serializable {
private final Entry<K, V> delegate;
private final Object mutex;
TestEntry(Entry<K, V> delegate, Object mutex) {
this.delegate = delegate;
this.mutex = mutex;
Reported by PMD.
Line: 55
static class TestEntry<K, V> extends ForwardingMapEntry<K, V> implements Serializable {
private final Entry<K, V> delegate;
private final Object mutex;
TestEntry(Entry<K, V> delegate, Object mutex) {
this.delegate = delegate;
this.mutex = mutex;
}
Reported by PMD.
Line: 101
}
static class TestMap<K, V> extends SynchronizedMapTest.TestMap<K, V>
implements NavigableMap<K, V> {
public TestMap(NavigableMap<K, V> delegate, Object mutex) {
super(delegate, mutex);
}
Reported by PMD.
Line: 115
@Override
public Entry<K, V> ceilingEntry(K key) {
assertTrue(Thread.holdsLock(mutex));
return delegate().ceilingEntry(key);
}
@Override
public K ceilingKey(K key) {
assertTrue(Thread.holdsLock(mutex));
Reported by PMD.
Line: 121
@Override
public K ceilingKey(K key) {
assertTrue(Thread.holdsLock(mutex));
return delegate().ceilingKey(key);
}
@Override
public NavigableSet<K> descendingKeySet() {
assertTrue(Thread.holdsLock(mutex));
Reported by PMD.
android/guava-tests/test/com/google/common/collect/QueuesTest.java
89 issues
Line: 50
* @author Dimitris Andreou
*/
public class QueuesTest extends TestCase {
/*
* All the following tests relate to BlockingQueue methods in Queues.
*/
public static List<BlockingQueue<Object>> blockingQueues() {
Reported by PMD.
Line: 70
* We need to perform operations in a thread pool, even for simple cases, because the queue might
* be a SynchronousQueue.
*/
private ExecutorService threadPool;
@Override
public void setUp() {
threadPool = newCachedThreadPool();
}
Reported by PMD.
Line: 72
*/
private ExecutorService threadPool;
@Override
public void setUp() {
threadPool = newCachedThreadPool();
}
@Override
Reported by PMD.
Line: 77
threadPool = newCachedThreadPool();
}
@Override
public void tearDown() throws InterruptedException {
threadPool.shutdown();
assertTrue("Some worker didn't finish in time", threadPool.awaitTermination(10, SECONDS));
}
Reported by PMD.
Line: 96
: Queues.drainUninterruptibly(q, buffer, maxElements, timeout, unit);
}
public void testMultipleProducers() throws Exception {
for (BlockingQueue<Object> q : blockingQueues()) {
testMultipleProducers(q);
}
}
Reported by PMD.
Line: 96
: Queues.drainUninterruptibly(q, buffer, maxElements, timeout, unit);
}
public void testMultipleProducers() throws Exception {
for (BlockingQueue<Object> q : blockingQueues()) {
testMultipleProducers(q);
}
}
Reported by PMD.
Line: 102
}
}
private void testMultipleProducers(BlockingQueue<Object> q) throws InterruptedException {
for (boolean interruptibly : new boolean[] {true, false}) {
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError1 = threadPool.submit(new Producer(q, 20));
Reported by PMD.
Line: 104
private void testMultipleProducers(BlockingQueue<Object> q) throws InterruptedException {
for (boolean interruptibly : new boolean[] {true, false}) {
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError1 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError2 = threadPool.submit(new Producer(q, 20));
Reported by PMD.
Line: 105
private void testMultipleProducers(BlockingQueue<Object> q) throws InterruptedException {
for (boolean interruptibly : new boolean[] {true, false}) {
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError1 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError2 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Reported by PMD.
Line: 107
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError1 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError2 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError3 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Reported by PMD.
guava-tests/test/com/google/common/collect/CompactLinkedHashMapTest.java
89 issues
Line: 37
* @author Louis Wasserman
*/
public class CompactLinkedHashMapTest extends TestCase {
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTest(
MapTestSuiteBuilder.using(
new TestStringMapGenerator() {
@Override
Reported by PMD.
Line: 67
@Override
protected Map<String, String> create(Entry<String, String>[] entries) {
CompactLinkedHashMap<String, String> map = CompactLinkedHashMap.create();
map.convertToHashFloodingResistantImplementation();
for (Entry<String, String> entry : entries) {
map.put(entry.getKey(), entry.getValue());
}
return map;
}
Reported by PMD.
Line: 89
return suite;
}
public void testInsertionOrder() {
Map<Integer, String> map = CompactLinkedHashMap.create();
map.put(1, "a");
map.put(4, "b");
map.put(3, "d");
map.put(2, "c");
Reported by PMD.
Line: 89
return suite;
}
public void testInsertionOrder() {
Map<Integer, String> map = CompactLinkedHashMap.create();
map.put(1, "a");
map.put(4, "b");
map.put(3, "d");
map.put(2, "c");
Reported by PMD.
Line: 91
public void testInsertionOrder() {
Map<Integer, String> map = CompactLinkedHashMap.create();
map.put(1, "a");
map.put(4, "b");
map.put(3, "d");
map.put(2, "c");
testHasMapEntriesInOrder(map, 1, "a", 4, "b", 3, "d", 2, "c");
}
Reported by PMD.
Line: 92
public void testInsertionOrder() {
Map<Integer, String> map = CompactLinkedHashMap.create();
map.put(1, "a");
map.put(4, "b");
map.put(3, "d");
map.put(2, "c");
testHasMapEntriesInOrder(map, 1, "a", 4, "b", 3, "d", 2, "c");
}
Reported by PMD.
Line: 93
Map<Integer, String> map = CompactLinkedHashMap.create();
map.put(1, "a");
map.put(4, "b");
map.put(3, "d");
map.put(2, "c");
testHasMapEntriesInOrder(map, 1, "a", 4, "b", 3, "d", 2, "c");
}
public void testInsertionOrderAfterPutKeyTwice() {
Reported by PMD.
Line: 94
map.put(1, "a");
map.put(4, "b");
map.put(3, "d");
map.put(2, "c");
testHasMapEntriesInOrder(map, 1, "a", 4, "b", 3, "d", 2, "c");
}
public void testInsertionOrderAfterPutKeyTwice() {
Map<Integer, String> map = CompactLinkedHashMap.create();
Reported by PMD.
Line: 98
testHasMapEntriesInOrder(map, 1, "a", 4, "b", 3, "d", 2, "c");
}
public void testInsertionOrderAfterPutKeyTwice() {
Map<Integer, String> map = CompactLinkedHashMap.create();
map.put(1, "a");
map.put(4, "b");
map.put(3, "d");
map.put(2, "c");
Reported by PMD.
Line: 98
testHasMapEntriesInOrder(map, 1, "a", 4, "b", 3, "d", 2, "c");
}
public void testInsertionOrderAfterPutKeyTwice() {
Map<Integer, String> map = CompactLinkedHashMap.create();
map.put(1, "a");
map.put(4, "b");
map.put(3, "d");
map.put(2, "c");
Reported by PMD.
guava-tests/test/com/google/common/collect/QueuesTest.java
89 issues
Line: 50
* @author Dimitris Andreou
*/
public class QueuesTest extends TestCase {
/*
* All the following tests relate to BlockingQueue methods in Queues.
*/
public static List<BlockingQueue<Object>> blockingQueues() {
Reported by PMD.
Line: 70
* We need to perform operations in a thread pool, even for simple cases, because the queue might
* be a SynchronousQueue.
*/
private ExecutorService threadPool;
@Override
public void setUp() {
threadPool = newCachedThreadPool();
}
Reported by PMD.
Line: 72
*/
private ExecutorService threadPool;
@Override
public void setUp() {
threadPool = newCachedThreadPool();
}
@Override
Reported by PMD.
Line: 77
threadPool = newCachedThreadPool();
}
@Override
public void tearDown() throws InterruptedException {
threadPool.shutdown();
assertTrue("Some worker didn't finish in time", threadPool.awaitTermination(10, SECONDS));
}
Reported by PMD.
Line: 96
: Queues.drainUninterruptibly(q, buffer, maxElements, timeout, unit);
}
public void testMultipleProducers() throws Exception {
for (BlockingQueue<Object> q : blockingQueues()) {
testMultipleProducers(q);
}
}
Reported by PMD.
Line: 96
: Queues.drainUninterruptibly(q, buffer, maxElements, timeout, unit);
}
public void testMultipleProducers() throws Exception {
for (BlockingQueue<Object> q : blockingQueues()) {
testMultipleProducers(q);
}
}
Reported by PMD.
Line: 102
}
}
private void testMultipleProducers(BlockingQueue<Object> q) throws InterruptedException {
for (boolean interruptibly : new boolean[] {true, false}) {
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError1 = threadPool.submit(new Producer(q, 20));
Reported by PMD.
Line: 104
private void testMultipleProducers(BlockingQueue<Object> q) throws InterruptedException {
for (boolean interruptibly : new boolean[] {true, false}) {
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError1 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError2 = threadPool.submit(new Producer(q, 20));
Reported by PMD.
Line: 105
private void testMultipleProducers(BlockingQueue<Object> q) throws InterruptedException {
for (boolean interruptibly : new boolean[] {true, false}) {
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError1 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError2 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Reported by PMD.
Line: 107
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError1 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError2 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Future<?> possiblyIgnoredError3 = threadPool.submit(new Producer(q, 20));
@SuppressWarnings("unused") // https://errorprone.info/bugpattern/FutureReturnValueIgnored
Reported by PMD.