The following issues were found
android/guava-tests/test/com/google/common/io/MultiInputStreamTest.java
33 issues
Line: 34
*/
public class MultiInputStreamTest extends IoTestCase {
public void testJoin() throws Exception {
joinHelper(0);
joinHelper(1);
joinHelper(0, 0, 0);
joinHelper(10, 20);
joinHelper(10, 0, 20);
Reported by PMD.
Line: 47
joinHelper(1, 0, 1, 0, 1, 0, 1, 0);
}
public void testOnlyOneOpen() throws Exception {
final ByteSource source = newByteSource(0, 50);
final int[] counter = new int[1];
ByteSource checker =
new ByteSource() {
@Override
Reported by PMD.
Line: 54
new ByteSource() {
@Override
public InputStream openStream() throws IOException {
if (counter[0]++ != 0) {
throw new IllegalStateException("More than one source open");
}
return new FilterInputStream(source.openStream()) {
@Override
public void close() throws IOException {
Reported by PMD.
Line: 66
};
}
};
byte[] result = ByteSource.concat(checker, checker, checker).read();
assertEquals(150, result.length);
}
private void joinHelper(Integer... spans) throws Exception {
List<ByteSource> sources = Lists.newArrayList();
Reported by PMD.
Line: 70
assertEquals(150, result.length);
}
private void joinHelper(Integer... spans) throws Exception {
List<ByteSource> sources = Lists.newArrayList();
int start = 0;
for (Integer span : spans) {
sources.add(newByteSource(start, span));
start += span;
Reported by PMD.
Line: 78
start += span;
}
ByteSource joined = ByteSource.concat(sources);
assertTrue(newByteSource(0, start).contentEquals(joined));
}
public void testReadSingleByte() throws Exception {
ByteSource source = newByteSource(0, 10);
ByteSource joined = ByteSource.concat(source, source);
Reported by PMD.
Line: 81
assertTrue(newByteSource(0, start).contentEquals(joined));
}
public void testReadSingleByte() throws Exception {
ByteSource source = newByteSource(0, 10);
ByteSource joined = ByteSource.concat(source, source);
assertEquals(20, joined.size());
InputStream in = joined.openStream();
assertFalse(in.markSupported());
Reported by PMD.
Line: 81
assertTrue(newByteSource(0, start).contentEquals(joined));
}
public void testReadSingleByte() throws Exception {
ByteSource source = newByteSource(0, 10);
ByteSource joined = ByteSource.concat(source, source);
assertEquals(20, joined.size());
InputStream in = joined.openStream();
assertFalse(in.markSupported());
Reported by PMD.
Line: 84
public void testReadSingleByte() throws Exception {
ByteSource source = newByteSource(0, 10);
ByteSource joined = ByteSource.concat(source, source);
assertEquals(20, joined.size());
InputStream in = joined.openStream();
assertFalse(in.markSupported());
assertEquals(10, in.available());
int total = 0;
while (in.read() != -1) {
Reported by PMD.
Line: 85
ByteSource source = newByteSource(0, 10);
ByteSource joined = ByteSource.concat(source, source);
assertEquals(20, joined.size());
InputStream in = joined.openStream();
assertFalse(in.markSupported());
assertEquals(10, in.available());
int total = 0;
while (in.read() != -1) {
total++;
Reported by PMD.
android/guava-tests/test/com/google/common/collect/SubMapMultimapAsMapImplementsMapTest.java
33 issues
Line: 40
private TreeMultimap<String, Integer> createMultimap() {
TreeMultimap<String, Integer> multimap =
TreeMultimap.create(
Ordering.<String>natural().nullsFirst(), Ordering.<Integer>natural().nullsFirst());
multimap.put("a", -1);
multimap.put("a", -3);
multimap.put("z", -2);
return multimap;
}
Reported by PMD.
Line: 40
private TreeMultimap<String, Integer> createMultimap() {
TreeMultimap<String, Integer> multimap =
TreeMultimap.create(
Ordering.<String>natural().nullsFirst(), Ordering.<Integer>natural().nullsFirst());
multimap.put("a", -1);
multimap.put("a", -3);
multimap.put("z", -2);
return multimap;
}
Reported by PMD.
Line: 40
private TreeMultimap<String, Integer> createMultimap() {
TreeMultimap<String, Integer> multimap =
TreeMultimap.create(
Ordering.<String>natural().nullsFirst(), Ordering.<Integer>natural().nullsFirst());
multimap.put("a", -1);
multimap.put("a", -3);
multimap.put("z", -2);
return multimap;
}
Reported by PMD.
Line: 40
private TreeMultimap<String, Integer> createMultimap() {
TreeMultimap<String, Integer> multimap =
TreeMultimap.create(
Ordering.<String>natural().nullsFirst(), Ordering.<Integer>natural().nullsFirst());
multimap.put("a", -1);
multimap.put("a", -3);
multimap.put("z", -2);
return multimap;
}
Reported by PMD.
Line: 41
TreeMultimap<String, Integer> multimap =
TreeMultimap.create(
Ordering.<String>natural().nullsFirst(), Ordering.<Integer>natural().nullsFirst());
multimap.put("a", -1);
multimap.put("a", -3);
multimap.put("z", -2);
return multimap;
}
Reported by PMD.
Line: 42
TreeMultimap.create(
Ordering.<String>natural().nullsFirst(), Ordering.<Integer>natural().nullsFirst());
multimap.put("a", -1);
multimap.put("a", -3);
multimap.put("z", -2);
return multimap;
}
@Override
Reported by PMD.
Line: 43
Ordering.<String>natural().nullsFirst(), Ordering.<Integer>natural().nullsFirst());
multimap.put("a", -1);
multimap.put("a", -3);
multimap.put("z", -2);
return multimap;
}
@Override
protected Map<String, Collection<Integer>> makeEmptyMap() {
Reported by PMD.
Line: 49
@Override
protected Map<String, Collection<Integer>> makeEmptyMap() {
return createMultimap().asMap().subMap("e", "p");
}
@Override
protected Map<String, Collection<Integer>> makePopulatedMap() {
TreeMultimap<String, Integer> multimap = createMultimap();
Reported by PMD.
Line: 49
@Override
protected Map<String, Collection<Integer>> makeEmptyMap() {
return createMultimap().asMap().subMap("e", "p");
}
@Override
protected Map<String, Collection<Integer>> makePopulatedMap() {
TreeMultimap<String, Integer> multimap = createMultimap();
Reported by PMD.
Line: 55
@Override
protected Map<String, Collection<Integer>> makePopulatedMap() {
TreeMultimap<String, Integer> multimap = createMultimap();
multimap.put("f", 1);
multimap.put("f", 2);
multimap.put("g", 3);
multimap.put("h", 4);
return multimap.asMap().subMap("e", "p");
}
Reported by PMD.
guava/src/com/google/common/cache/CacheBuilderSpec.java
33 issues
Line: 84
@SuppressWarnings("GoodTime") // lots of violations (nanosecond math)
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class CacheBuilderSpec {
/** Parses a single value. */
private interface ValueParser {
void parse(CacheBuilderSpec spec, String key, @CheckForNull String value);
}
Reported by PMD.
Line: 84
@SuppressWarnings("GoodTime") // lots of violations (nanosecond math)
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class CacheBuilderSpec {
/** Parses a single value. */
private interface ValueParser {
void parse(CacheBuilderSpec spec, String key, @CheckForNull String value);
}
Reported by PMD.
Line: 113
.put("refreshInterval", new RefreshDurationParser())
.build();
@VisibleForTesting @CheckForNull Integer initialCapacity;
@VisibleForTesting @CheckForNull Long maximumSize;
@VisibleForTesting @CheckForNull Long maximumWeight;
@VisibleForTesting @CheckForNull Integer concurrencyLevel;
@VisibleForTesting @CheckForNull Strength keyStrength;
@VisibleForTesting @CheckForNull Strength valueStrength;
Reported by PMD.
Line: 114
.build();
@VisibleForTesting @CheckForNull Integer initialCapacity;
@VisibleForTesting @CheckForNull Long maximumSize;
@VisibleForTesting @CheckForNull Long maximumWeight;
@VisibleForTesting @CheckForNull Integer concurrencyLevel;
@VisibleForTesting @CheckForNull Strength keyStrength;
@VisibleForTesting @CheckForNull Strength valueStrength;
@VisibleForTesting @CheckForNull Boolean recordStats;
Reported by PMD.
Line: 115
@VisibleForTesting @CheckForNull Integer initialCapacity;
@VisibleForTesting @CheckForNull Long maximumSize;
@VisibleForTesting @CheckForNull Long maximumWeight;
@VisibleForTesting @CheckForNull Integer concurrencyLevel;
@VisibleForTesting @CheckForNull Strength keyStrength;
@VisibleForTesting @CheckForNull Strength valueStrength;
@VisibleForTesting @CheckForNull Boolean recordStats;
@VisibleForTesting long writeExpirationDuration;
Reported by PMD.
Line: 116
@VisibleForTesting @CheckForNull Integer initialCapacity;
@VisibleForTesting @CheckForNull Long maximumSize;
@VisibleForTesting @CheckForNull Long maximumWeight;
@VisibleForTesting @CheckForNull Integer concurrencyLevel;
@VisibleForTesting @CheckForNull Strength keyStrength;
@VisibleForTesting @CheckForNull Strength valueStrength;
@VisibleForTesting @CheckForNull Boolean recordStats;
@VisibleForTesting long writeExpirationDuration;
@VisibleForTesting @CheckForNull TimeUnit writeExpirationTimeUnit;
Reported by PMD.
Line: 117
@VisibleForTesting @CheckForNull Long maximumSize;
@VisibleForTesting @CheckForNull Long maximumWeight;
@VisibleForTesting @CheckForNull Integer concurrencyLevel;
@VisibleForTesting @CheckForNull Strength keyStrength;
@VisibleForTesting @CheckForNull Strength valueStrength;
@VisibleForTesting @CheckForNull Boolean recordStats;
@VisibleForTesting long writeExpirationDuration;
@VisibleForTesting @CheckForNull TimeUnit writeExpirationTimeUnit;
@VisibleForTesting long accessExpirationDuration;
Reported by PMD.
Line: 118
@VisibleForTesting @CheckForNull Long maximumWeight;
@VisibleForTesting @CheckForNull Integer concurrencyLevel;
@VisibleForTesting @CheckForNull Strength keyStrength;
@VisibleForTesting @CheckForNull Strength valueStrength;
@VisibleForTesting @CheckForNull Boolean recordStats;
@VisibleForTesting long writeExpirationDuration;
@VisibleForTesting @CheckForNull TimeUnit writeExpirationTimeUnit;
@VisibleForTesting long accessExpirationDuration;
@VisibleForTesting @CheckForNull TimeUnit accessExpirationTimeUnit;
Reported by PMD.
Line: 119
@VisibleForTesting @CheckForNull Integer concurrencyLevel;
@VisibleForTesting @CheckForNull Strength keyStrength;
@VisibleForTesting @CheckForNull Strength valueStrength;
@VisibleForTesting @CheckForNull Boolean recordStats;
@VisibleForTesting long writeExpirationDuration;
@VisibleForTesting @CheckForNull TimeUnit writeExpirationTimeUnit;
@VisibleForTesting long accessExpirationDuration;
@VisibleForTesting @CheckForNull TimeUnit accessExpirationTimeUnit;
@VisibleForTesting long refreshDuration;
Reported by PMD.
Line: 120
@VisibleForTesting @CheckForNull Strength keyStrength;
@VisibleForTesting @CheckForNull Strength valueStrength;
@VisibleForTesting @CheckForNull Boolean recordStats;
@VisibleForTesting long writeExpirationDuration;
@VisibleForTesting @CheckForNull TimeUnit writeExpirationTimeUnit;
@VisibleForTesting long accessExpirationDuration;
@VisibleForTesting @CheckForNull TimeUnit accessExpirationTimeUnit;
@VisibleForTesting long refreshDuration;
@VisibleForTesting @CheckForNull TimeUnit refreshTimeUnit;
Reported by PMD.
guava/src/com/google/common/collect/ForwardingNavigableMap.java
33 issues
Line: 61
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingNavigableMap<K extends @Nullable Object, V extends @Nullable Object>
extends ForwardingSortedMap<K, V> implements NavigableMap<K, V> {
/** Constructor for use by subclasses. */
protected ForwardingNavigableMap() {}
@Override
Reported by PMD.
Line: 72
@Override
@CheckForNull
public Entry<K, V> lowerEntry(@ParametricNullness K key) {
return delegate().lowerEntry(key);
}
/**
* A sensible definition of {@link #lowerEntry} in terms of the {@code lastEntry()} of {@link
* #headMap(Object, boolean)}. If you override {@code headMap}, you may wish to override {@code
Reported by PMD.
Line: 82
*/
@CheckForNull
protected Entry<K, V> standardLowerEntry(@ParametricNullness K key) {
return headMap(key, false).lastEntry();
}
@Override
@CheckForNull
public K lowerKey(@ParametricNullness K key) {
Reported by PMD.
Line: 88
@Override
@CheckForNull
public K lowerKey(@ParametricNullness K key) {
return delegate().lowerKey(key);
}
/**
* A sensible definition of {@link #lowerKey} in terms of {@code lowerEntry}. If you override
* {@link #lowerEntry}, you may wish to override {@code lowerKey} to forward to this
Reported by PMD.
Line: 104
@Override
@CheckForNull
public Entry<K, V> floorEntry(@ParametricNullness K key) {
return delegate().floorEntry(key);
}
/**
* A sensible definition of {@link #floorEntry} in terms of the {@code lastEntry()} of {@link
* #headMap(Object, boolean)}. If you override {@code headMap}, you may wish to override {@code
Reported by PMD.
Line: 114
*/
@CheckForNull
protected Entry<K, V> standardFloorEntry(@ParametricNullness K key) {
return headMap(key, true).lastEntry();
}
@Override
@CheckForNull
public K floorKey(@ParametricNullness K key) {
Reported by PMD.
Line: 120
@Override
@CheckForNull
public K floorKey(@ParametricNullness K key) {
return delegate().floorKey(key);
}
/**
* A sensible definition of {@link #floorKey} in terms of {@code floorEntry}. If you override
* {@code floorEntry}, you may wish to override {@code floorKey} to forward to this
Reported by PMD.
Line: 136
@Override
@CheckForNull
public Entry<K, V> ceilingEntry(@ParametricNullness K key) {
return delegate().ceilingEntry(key);
}
/**
* A sensible definition of {@link #ceilingEntry} in terms of the {@code firstEntry()} of {@link
* #tailMap(Object, boolean)}. If you override {@code tailMap}, you may wish to override {@code
Reported by PMD.
Line: 146
*/
@CheckForNull
protected Entry<K, V> standardCeilingEntry(@ParametricNullness K key) {
return tailMap(key, true).firstEntry();
}
@Override
@CheckForNull
public K ceilingKey(@ParametricNullness K key) {
Reported by PMD.
Line: 152
@Override
@CheckForNull
public K ceilingKey(@ParametricNullness K key) {
return delegate().ceilingKey(key);
}
/**
* A sensible definition of {@link #ceilingKey} in terms of {@code ceilingEntry}. If you override
* {@code ceilingEntry}, you may wish to override {@code ceilingKey} to forward to this
Reported by PMD.
guava/src/com/google/common/collect/ImmutableSet.java
33 issues
Line: 653
* can hold setSize elements with the desired load factor. Always returns at least setSize + 2.
*/
// TODO(cpovirk): Move to Hashing or something, since it's used elsewhere in the Android version.
static int chooseTableSize(int setSize) {
setSize = Math.max(setSize, 2);
// Correct the size for open addressing to match desired load factor.
if (setSize < CUTOFF) {
// Round up to the next highest power of 2.
int tableSize = Integer.highestOneBit(setSize - 1) << 1;
Reported by PMD.
Line: 56
@GwtCompatible(serializable = true, emulated = true)
@SuppressWarnings("serial") // we're overriding default serialization
@ElementTypesAreNonnullByDefault
public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements Set<E> {
static final int SPLITERATOR_CHARACTERISTICS =
ImmutableCollection.SPLITERATOR_CHARACTERISTICS | Spliterator.DISTINCT;
/**
* Returns a {@code Collector} that accumulates the input elements into a new {@code
Reported by PMD.
Line: 78
*
* <p><b>Performance note:</b> the instance returned is a singleton.
*/
@SuppressWarnings({"unchecked"}) // fully variant implementation (never actually produces any Es)
public static <E> ImmutableSet<E> of() {
return (ImmutableSet<E>) RegularImmutableSet.EMPTY;
}
/**
Reported by PMD.
Line: 207
E e = (E) checkNotNull(elements[i]);
builder = builder.add(e);
}
return builder.review().build();
}
}
/**
* Returns an immutable set containing each of {@code elements}, minus duplicates, in the order
Reported by PMD.
Line: 232
if (elements instanceof ImmutableSet && !(elements instanceof SortedSet)) {
@SuppressWarnings("unchecked") // all supported methods are covariant
ImmutableSet<E> set = (ImmutableSet<E>) elements;
if (!set.isPartialView()) {
return set;
}
} else if (elements instanceof EnumSet) {
return copyOfEnumSet((EnumSet) elements);
}
Reported by PMD.
Line: 338
@Override
public abstract UnmodifiableIterator<E> iterator();
@LazyInit @RetainedWith @CheckForNull private transient ImmutableList<E> asList;
@Override
public ImmutableList<E> asList() {
ImmutableList<E> result = asList;
return (result == null) ? asList = createAsList() : result;
Reported by PMD.
Line: 355
@Override
public UnmodifiableIterator<E> iterator() {
return asList().iterator();
}
@Override
public Spliterator<E> spliterator() {
return CollectSpliterators.indexed(size(), SPLITERATOR_CHARACTERISTICS, this::get);
Reported by PMD.
Line: 374
@Override
int copyIntoArray(@Nullable Object[] dst, int offset) {
return asList().copyIntoArray(dst, offset);
}
@Override
ImmutableList<E> createAsList() {
return new ImmutableAsList<E>() {
Reported by PMD.
Line: 382
return new ImmutableAsList<E>() {
@Override
public E get(int index) {
return Indexed.this.get(index);
}
@Override
Indexed<E> delegateCollection() {
return Indexed.this;
Reported by PMD.
Line: 382
return new ImmutableAsList<E>() {
@Override
public E get(int index) {
return Indexed.this.get(index);
}
@Override
Indexed<E> delegateCollection() {
return Indexed.this;
Reported by PMD.
guava/src/com/google/common/util/concurrent/Striped.java
32 issues
Line: 560
* java.util.HashMap class.
*/
// Copied from java/com/google/common/collect/Hashing.java
private static int smear(int hashCode) {
hashCode ^= (hashCode >>> 20) ^ (hashCode >>> 12);
return hashCode ^ (hashCode >>> 7) ^ (hashCode >>> 4);
}
private static class PaddedLock extends ReentrantLock {
Reported by PMD.
Line: 88
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class Striped<L> {
/**
* If there are at least this many stripes, we assume the memory usage of a ConcurrentMap will be
* smaller than a large array. (This assumes that in the lazy case, most stripes are unused. As
* always, if many stripes are in use, a non-lazy striped makes more sense.)
*/
Reported by PMD.
Line: 145
public Iterable<L> bulkGet(Iterable<? extends Object> keys) {
// Initially using the list to store the keys, then reusing it to store the respective L's
List<Object> result = newArrayList(keys);
if (result.isEmpty()) {
return ImmutableList.of();
}
int[] stripes = new int[result.size()];
for (int i = 0; i < result.size(); i++) {
stripes[i] = indexFor(result.get(i));
Reported by PMD.
Line: 148
if (result.isEmpty()) {
return ImmutableList.of();
}
int[] stripes = new int[result.size()];
for (int i = 0; i < result.size(); i++) {
stripes[i] = indexFor(result.get(i));
}
Arrays.sort(stripes);
// optimize for runs of identical stripes
Reported by PMD.
Line: 155
Arrays.sort(stripes);
// optimize for runs of identical stripes
int previousStripe = stripes[0];
result.set(0, getAt(previousStripe));
for (int i = 1; i < result.size(); i++) {
int currentStripe = stripes[i];
if (currentStripe == previousStripe) {
result.set(i, result.get(i - 1));
} else {
Reported by PMD.
Line: 325
* the {@code ReadWriteLock} is retained.
*/
private static final class WeakSafeReadWriteLock implements ReadWriteLock {
private final ReadWriteLock delegate;
WeakSafeReadWriteLock() {
this.delegate = new ReentrantReadWriteLock();
}
Reported by PMD.
Line: 344
/** Lock object that ensures a strong reference is retained to a specified object. */
private static final class WeakSafeLock extends ForwardingLock {
private final Lock delegate;
@SuppressWarnings("unused")
private final WeakSafeReadWriteLock strongReference;
WeakSafeLock(Lock delegate, WeakSafeReadWriteLock strongReference) {
Reported by PMD.
Line: 344
/** Lock object that ensures a strong reference is retained to a specified object. */
private static final class WeakSafeLock extends ForwardingLock {
private final Lock delegate;
@SuppressWarnings("unused")
private final WeakSafeReadWriteLock strongReference;
WeakSafeLock(Lock delegate, WeakSafeReadWriteLock strongReference) {
Reported by PMD.
Line: 347
private final Lock delegate;
@SuppressWarnings("unused")
private final WeakSafeReadWriteLock strongReference;
WeakSafeLock(Lock delegate, WeakSafeReadWriteLock strongReference) {
this.delegate = delegate;
this.strongReference = strongReference;
}
Reported by PMD.
Line: 367
/** Condition object that ensures a strong reference is retained to a specified object. */
private static final class WeakSafeCondition extends ForwardingCondition {
private final Condition delegate;
@SuppressWarnings("unused")
private final WeakSafeReadWriteLock strongReference;
WeakSafeCondition(Condition delegate, WeakSafeReadWriteLock strongReference) {
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/FuturesGetUncheckedTest.java
32 issues
Line: 40
/** Unit tests for {@link Futures#getUnchecked(Future)}. */
@GwtCompatible(emulated = true)
public class FuturesGetUncheckedTest extends TestCase {
public void testGetUnchecked_success() {
assertEquals("foo", getUnchecked(immediateFuture("foo")));
}
@GwtIncompatible // Thread.interrupt
public void testGetUnchecked_interrupted() {
Reported by PMD.
Line: 41
@GwtCompatible(emulated = true)
public class FuturesGetUncheckedTest extends TestCase {
public void testGetUnchecked_success() {
assertEquals("foo", getUnchecked(immediateFuture("foo")));
}
@GwtIncompatible // Thread.interrupt
public void testGetUnchecked_interrupted() {
Thread.currentThread().interrupt();
Reported by PMD.
Line: 41
@GwtCompatible(emulated = true)
public class FuturesGetUncheckedTest extends TestCase {
public void testGetUnchecked_success() {
assertEquals("foo", getUnchecked(immediateFuture("foo")));
}
@GwtIncompatible // Thread.interrupt
public void testGetUnchecked_interrupted() {
Thread.currentThread().interrupt();
Reported by PMD.
Line: 44
assertEquals("foo", getUnchecked(immediateFuture("foo")));
}
@GwtIncompatible // Thread.interrupt
public void testGetUnchecked_interrupted() {
Thread.currentThread().interrupt();
try {
assertEquals("foo", getUnchecked(immediateFuture("foo")));
assertTrue(Thread.currentThread().isInterrupted());
Reported by PMD.
Line: 45
}
@GwtIncompatible // Thread.interrupt
public void testGetUnchecked_interrupted() {
Thread.currentThread().interrupt();
try {
assertEquals("foo", getUnchecked(immediateFuture("foo")));
assertTrue(Thread.currentThread().isInterrupted());
} finally {
Reported by PMD.
Line: 46
@GwtIncompatible // Thread.interrupt
public void testGetUnchecked_interrupted() {
Thread.currentThread().interrupt();
try {
assertEquals("foo", getUnchecked(immediateFuture("foo")));
assertTrue(Thread.currentThread().isInterrupted());
} finally {
Thread.interrupted();
Reported by PMD.
Line: 48
public void testGetUnchecked_interrupted() {
Thread.currentThread().interrupt();
try {
assertEquals("foo", getUnchecked(immediateFuture("foo")));
assertTrue(Thread.currentThread().isInterrupted());
} finally {
Thread.interrupted();
}
}
Reported by PMD.
Line: 49
Thread.currentThread().interrupt();
try {
assertEquals("foo", getUnchecked(immediateFuture("foo")));
assertTrue(Thread.currentThread().isInterrupted());
} finally {
Thread.interrupted();
}
}
Reported by PMD.
Line: 49
Thread.currentThread().interrupt();
try {
assertEquals("foo", getUnchecked(immediateFuture("foo")));
assertTrue(Thread.currentThread().isInterrupted());
} finally {
Thread.interrupted();
}
}
Reported by PMD.
Line: 55
}
}
public void testGetUnchecked_cancelled() {
SettableFuture<String> future = SettableFuture.create();
future.cancel(true);
try {
getUnchecked(future);
fail();
Reported by PMD.
guava/src/com/google/common/collect/DenseImmutableTable.java
32 issues
Line: 31
@GwtCompatible
@Immutable(containerOf = {"R", "C", "V"})
@ElementTypesAreNonnullByDefault
final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V> {
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;
Reported by PMD.
Line: 32
@Immutable(containerOf = {"R", "C", "V"})
@ElementTypesAreNonnullByDefault
final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V> {
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;
@SuppressWarnings("Immutable") // We don't modify this after construction.
Reported by PMD.
Line: 33
@ElementTypesAreNonnullByDefault
final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V> {
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;
@SuppressWarnings("Immutable") // We don't modify this after construction.
private final int[] rowCounts;
Reported by PMD.
Line: 34
final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V> {
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;
@SuppressWarnings("Immutable") // We don't modify this after construction.
private final int[] rowCounts;
Reported by PMD.
Line: 34
final class DenseImmutableTable<R, C, V> extends RegularImmutableTable<R, C, V> {
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;
@SuppressWarnings("Immutable") // We don't modify this after construction.
private final int[] rowCounts;
Reported by PMD.
Line: 35
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;
@SuppressWarnings("Immutable") // We don't modify this after construction.
private final int[] rowCounts;
@SuppressWarnings("Immutable") // We don't modify this after construction.
Reported by PMD.
Line: 35
private final ImmutableMap<R, Integer> rowKeyToIndex;
private final ImmutableMap<C, Integer> columnKeyToIndex;
private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;
@SuppressWarnings("Immutable") // We don't modify this after construction.
private final int[] rowCounts;
@SuppressWarnings("Immutable") // We don't modify this after construction.
Reported by PMD.
Line: 37
private final ImmutableMap<R, ImmutableMap<C, V>> rowMap;
private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;
@SuppressWarnings("Immutable") // We don't modify this after construction.
private final int[] rowCounts;
@SuppressWarnings("Immutable") // We don't modify this after construction.
private final int[] columnCounts;
Reported by PMD.
Line: 38
private final ImmutableMap<C, ImmutableMap<R, V>> columnMap;
@SuppressWarnings("Immutable") // We don't modify this after construction.
private final int[] rowCounts;
@SuppressWarnings("Immutable") // We don't modify this after construction.
private final int[] columnCounts;
@SuppressWarnings("Immutable") // We don't modify this after construction.
Reported by PMD.
Line: 41
private final int[] rowCounts;
@SuppressWarnings("Immutable") // We don't modify this after construction.
private final int[] columnCounts;
@SuppressWarnings("Immutable") // We don't modify this after construction.
private final @Nullable V[][] values;
// For each cell in iteration order, the index of that cell's row key in the row key list.
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/InterruptibleTaskTest.java
32 issues
Line: 81
static final class BrokenChannel extends AbstractInterruptibleChannel {
@Override
protected void implCloseChannel() {
throw new RuntimeException("I bet you didn't think Thread.interrupt could throw");
}
void doBegin() {
super.begin();
}
Reported by PMD.
Line: 168
throws InterruptedException {
while (!isThreadBlockedOnInstanceOf(t, blocker)) {
if (t.getState() == Thread.State.TERMINATED) {
throw new RuntimeException("Thread " + t + " exited unexpectedly");
}
Thread.sleep(1);
}
}
Reported by PMD.
Line: 33
// Regression test for a deadlock where a task could be stuck busy waiting for the task to
// transition to DONE
public void testInterruptThrows() throws Exception {
final CountDownLatch isInterruptibleRegistered = new CountDownLatch(1);
InterruptibleTask<Void> task =
new InterruptibleTask<Void>() {
@Override
Void runInterruptibly() throws Exception {
Reported by PMD.
Line: 67
isInterruptibleRegistered.await();
try {
task.interruptTask();
fail();
} catch (RuntimeException expected) {
assertThat(expected)
.hasMessageThat()
.isEqualTo("I bet you didn't think Thread.interrupt could throw");
}
Reported by PMD.
Line: 68
try {
task.interruptTask();
fail();
} catch (RuntimeException expected) {
assertThat(expected)
.hasMessageThat()
.isEqualTo("I bet you didn't think Thread.interrupt could throw");
}
// We need to wait for the runner to exit. It used to be that the runner would get stuck in the
Reported by PMD.
Line: 69
task.interruptTask();
fail();
} catch (RuntimeException expected) {
assertThat(expected)
.hasMessageThat()
.isEqualTo("I bet you didn't think Thread.interrupt could throw");
}
// We need to wait for the runner to exit. It used to be that the runner would get stuck in the
// busy loop when interrupt threw.
Reported by PMD.
Line: 69
task.interruptTask();
fail();
} catch (RuntimeException expected) {
assertThat(expected)
.hasMessageThat()
.isEqualTo("I bet you didn't think Thread.interrupt could throw");
}
// We need to wait for the runner to exit. It used to be that the runner would get stuck in the
// busy loop when interrupt threw.
Reported by PMD.
Line: 75
}
// We need to wait for the runner to exit. It used to be that the runner would get stuck in the
// busy loop when interrupt threw.
runner.join(TimeUnit.SECONDS.toMillis(10));
}
static final class BrokenChannel extends AbstractInterruptibleChannel {
@Override
protected void implCloseChannel() {
Reported by PMD.
Line: 94
* protect ourselves from that we want to make sure that tasks don't spin too much waiting for the
* interrupting thread to complete the protocol.
*/
public void testInterruptIsSlow() throws Exception {
final CountDownLatch isInterruptibleRegistered = new CountDownLatch(1);
final SlowChannel slowChannel = new SlowChannel();
final InterruptibleTask<Void> task =
new InterruptibleTask<Void>() {
@Override
Reported by PMD.
Line: 94
* protect ourselves from that we want to make sure that tasks don't spin too much waiting for the
* interrupting thread to complete the protocol.
*/
public void testInterruptIsSlow() throws Exception {
final CountDownLatch isInterruptibleRegistered = new CountDownLatch(1);
final SlowChannel slowChannel = new SlowChannel();
final InterruptibleTask<Void> task =
new InterruptibleTask<Void>() {
@Override
Reported by PMD.
guava/src/com/google/common/base/Splitter.java
32 issues
Line: 193
continue positions;
}
}
return p;
}
return -1;
}
@Override
Reported by PMD.
Line: 631
limit--;
}
return toSplit.subSequence(start, end).toString();
}
return endOfData();
}
}
}
Reported by PMD.
Line: 104
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
Reported by PMD.
Line: 105
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
Reported by PMD.
Line: 106
@ElementTypesAreNonnullByDefault
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
this(strategy, false, CharMatcher.none(), Integer.MAX_VALUE);
Reported by PMD.
Line: 106
@ElementTypesAreNonnullByDefault
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
this(strategy, false, CharMatcher.none(), Integer.MAX_VALUE);
Reported by PMD.
Line: 107
public final class Splitter {
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
this(strategy, false, CharMatcher.none(), Integer.MAX_VALUE);
}
Reported by PMD.
Line: 108
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
this(strategy, false, CharMatcher.none(), Integer.MAX_VALUE);
}
Reported by PMD.
Line: 108
private final CharMatcher trimmer;
private final boolean omitEmptyStrings;
private final Strategy strategy;
private final int limit;
private Splitter(Strategy strategy) {
this(strategy, false, CharMatcher.none(), Integer.MAX_VALUE);
}
Reported by PMD.
Line: 174
*/
public static Splitter on(final String separator) {
checkArgument(separator.length() != 0, "The separator may not be the empty string.");
if (separator.length() == 1) {
return Splitter.on(separator.charAt(0));
}
return new Splitter(
new Strategy() {
@Override
Reported by PMD.