The following issues were found
guava/src/com/google/common/collect/Iterables.java
32 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.collect.CollectPreconditions.checkRemove;
Reported by PMD.
Line: 69
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Iterables {
private Iterables() {}
/** Returns an unmodifiable view of {@code iterable}. */
public static <T extends @Nullable Object> Iterable<T> unmodifiableIterable(
final Iterable<? extends T> iterable) {
Reported by PMD.
Line: 69
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Iterables {
private Iterables() {}
/** Returns an unmodifiable view of {@code iterable}. */
public static <T extends @Nullable Object> Iterable<T> unmodifiableIterable(
final Iterable<? extends T> iterable) {
Reported by PMD.
Line: 69
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Iterables {
private Iterables() {}
/** Returns an unmodifiable view of {@code iterable}. */
public static <T extends @Nullable Object> Iterable<T> unmodifiableIterable(
final Iterable<? extends T> iterable) {
Reported by PMD.
Line: 97
private static final class UnmodifiableIterable<T extends @Nullable Object>
extends FluentIterable<T> {
private final Iterable<? extends T> iterable;
private UnmodifiableIterable(Iterable<? extends T> iterable) {
this.iterable = iterable;
}
Reported by PMD.
Line: 234
if (iterable1 instanceof Collection && iterable2 instanceof Collection) {
Collection<?> collection1 = (Collection<?>) iterable1;
Collection<?> collection2 = (Collection<?>) iterable2;
if (collection1.size() != collection2.size()) {
return false;
}
}
return Iterators.elementsEqual(iterable1.iterator(), iterable2.iterator());
}
Reported by PMD.
Line: 234
if (iterable1 instanceof Collection && iterable2 instanceof Collection) {
Collection<?> collection1 = (Collection<?>) iterable1;
Collection<?> collection2 = (Collection<?>) iterable2;
if (collection1.size() != collection2.size()) {
return false;
}
}
return Iterators.elementsEqual(iterable1.iterator(), iterable2.iterator());
}
Reported by PMD.
Line: 300
static <T extends @Nullable Object> T[] toArray(Iterable<? extends T> iterable, T[] array) {
Collection<? extends T> collection = castOrCopyToCollection(iterable);
return collection.toArray(array);
}
/**
* Copies an iterable's elements into an array.
*
Reported by PMD.
Line: 310
* @return a newly-allocated array into which all the elements of the iterable have been copied
*/
static @Nullable Object[] toArray(Iterable<?> iterable) {
return castOrCopyToCollection(iterable).toArray();
}
/**
* Converts an iterable into a collection. If the iterable is already a collection, it is
* returned. Otherwise, an {@link java.util.ArrayList} is created with the contents of the
Reported by PMD.
Line: 337
Collection<? extends T> c = (Collection<? extends T>) elementsToAdd;
return addTo.addAll(c);
}
return Iterators.addAll(addTo, checkNotNull(elementsToAdd).iterator());
}
/**
* Returns the number of elements in the specified iterable that equal the specified object. This
* implementation avoids a full iteration when the iterable is a {@link Multiset} or {@link Set}.
Reported by PMD.
android/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-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSortedSet.java
32 issues
Line: 332
return !set.isEmpty() ? set.last() : null;
}
public ImmutableSortedSet<E> headSet(E toElement, boolean inclusive) {
checkNotNull(toElement);
if (inclusive) {
E tmp = higher(toElement);
if (tmp == null) {
return this;
Reported by PMD.
Line: 373
}
}
public ImmutableSortedSet<E> tailSet(E fromElement, boolean inclusive) {
checkNotNull(fromElement);
if (!inclusive) {
E tmp = higher(fromElement);
if (tmp == null) {
return emptySet(comparator());
Reported by PMD.
Line: 39
* @author Hayward Chan
*/
public abstract class ImmutableSortedSet<E> extends ForwardingImmutableSet<E>
implements SortedSet<E>, SortedIterable<E> {
// TODO(cpovirk): split into ImmutableSortedSet/ForwardingImmutableSortedSet?
// In the non-emulated source, this is in ImmutableSortedSetFauxverideShim,
// which overrides ImmutableSet & which ImmutableSortedSet extends.
// It is necessary here because otherwise the builder() method
Reported by PMD.
Line: 54
}
// TODO: Can we find a way to remove this @SuppressWarnings even for eclipse?
@SuppressWarnings("unchecked")
private static final Comparator NATURAL_ORDER = Ordering.natural();
@SuppressWarnings("unchecked")
private static final ImmutableSortedSet<Object> NATURAL_EMPTY_SET =
new RegularImmutableSortedSet<Object>(new TreeSet<Object>(NATURAL_ORDER), false);
Reported by PMD.
Line: 119
private static <E> ImmutableSortedSet<E> ofInternal(
Comparator<? super E> comparator, E... elements) {
checkNotNull(elements);
switch (elements.length) {
case 0:
return emptySet(comparator);
default:
SortedSet<E> delegate = new TreeSet<E>(comparator);
for (E element : elements) {
Reported by PMD.
Line: 213
private static boolean hasSameComparator(Iterable<?> elements, Comparator<?> comparator) {
if (elements instanceof SortedSet) {
SortedSet<?> sortedSet = (SortedSet<?>) elements;
Comparator<?> comparator2 = sortedSet.comparator();
return (comparator2 == null)
? comparator == Ordering.natural()
: comparator.equals(comparator2);
}
return false;
Reported by PMD.
Line: 215
SortedSet<?> sortedSet = (SortedSet<?>) elements;
Comparator<?> comparator2 = sortedSet.comparator();
return (comparator2 == null)
? comparator == Ordering.natural()
: comparator.equals(comparator2);
}
return false;
}
Reported by PMD.
Line: 251
this.sortedDelegate = Collections.unmodifiableSortedSet(sortedDelegate);
}
public Comparator<? super E> comparator() {
return sortedDelegate.comparator();
}
@Override // needed to unify SortedIterable and Collection iterator() methods
public UnmodifiableIterator<E> iterator() {
Reported by PMD.
Line: 256
}
@Override // needed to unify SortedIterable and Collection iterator() methods
public UnmodifiableIterator<E> iterator() {
return super.iterator();
}
@Override
public Object[] toArray() {
Reported by PMD.
Line: 297
}
}
public E first() {
return sortedDelegate.first();
}
public ImmutableSortedSet<E> headSet(E toElement) {
checkNotNull(toElement);
Reported by PMD.
android/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.
android/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.
android/guava/src/com/google/common/collect/ForwardingNavigableMap.java
32 issues
Line: 60
@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: 71
@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: 81
*/
@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: 87
@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: 103
@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: 113
*/
@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: 119
@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: 135
@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: 145
*/
@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: 151
@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.
android/guava/src/com/google/common/util/concurrent/ServiceManager.java
32 issues
Line: 277
// service or listener). Our contract says it is safe to call this method if
// all services were NEW when it was called, and this has already been verified above, so we
// don't propagate the exception.
logger.log(Level.WARNING, "Unable to start Service " + service, e);
}
}
return this;
}
Reported by PMD.
Line: 795
// there is a higher likelihood that the cause will be in the logs.
boolean log = !(service instanceof NoOpService);
if (log) {
logger.log(
Level.SEVERE,
"Service " + service + " has failed in the " + from + " state.",
failure);
}
state.transitionService(service, from, FAILED);
Reported by PMD.
Line: 15
* the License.
*/
package com.google.common.util.concurrent;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Preconditions.checkState;
import static com.google.common.base.Predicates.equalTo;
Reported by PMD.
Line: 158
* @author Luke Sandberg
* @since 15.0 (present as an interface in 14.0)
*/
public abstract static class Listener {
/**
* Called when the service initially becomes healthy.
*
* <p>This will be called at most once after all the services have entered the {@linkplain
* State#RUNNING running} state. If any services fail during start up or {@linkplain
Reported by PMD.
Line: 190
* ServiceManager} constructor without having to close over the partially constructed {@link
* ServiceManager} instance (i.e. avoid leaking a pointer to {@code this}).
*/
private final ServiceManagerState state;
private final ImmutableList<Service> services;
/**
* Constructs a new instance for managing the given services.
Reported by PMD.
Line: 192
*/
private final ServiceManagerState state;
private final ImmutableList<Service> services;
/**
* Constructs a new instance for managing the given services.
*
* @param services The services to manage
Reported by PMD.
Line: 216
this.services = copy;
WeakReference<ServiceManagerState> stateReference = new WeakReference<>(state);
for (Service service : copy) {
service.addListener(new ServiceListener(service, stateReference), directExecutor());
// We check the state after adding the listener as a way to ensure that our listener was added
// to a NEW service.
checkArgument(service.state() == NEW, "Can only manage NEW services, %s", service);
}
// We have installed all of our listeners and after this point any state transition should be
Reported by PMD.
Line: 389
@Override
public String toString() {
return MoreObjects.toStringHelper(ServiceManager.class)
.add("services", Collections2.filter(services, not(instanceOf(NoOpService.class))))
.toString();
}
/**
Reported by PMD.
Line: 389
@Override
public String toString() {
return MoreObjects.toStringHelper(ServiceManager.class)
.add("services", Collections2.filter(services, not(instanceOf(NoOpService.class))))
.toString();
}
/**
Reported by PMD.
Line: 398
* An encapsulation of all the mutable state of the {@link ServiceManager} that needs to be
* accessed by instances of {@link ServiceListener}.
*/
private static final class ServiceManagerState {
final Monitor monitor = new Monitor();
@GuardedBy("monitor")
final SetMultimap<State, Service> servicesByState =
MultimapBuilder.enumKeys(State.class).linkedHashSetValues().build();
Reported by PMD.
android/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-tests/test/com/google/common/io/MoreFilesFileTraverserTest.java
32 issues
Line: 36
* @author Jens Nyman
*/
public class MoreFilesFileTraverserTest extends TestCase {
private Path rootDir;
@Override
public void setUp() throws IOException {
Reported by PMD.
Line: 38
public class MoreFilesFileTraverserTest extends TestCase {
private Path rootDir;
@Override
public void setUp() throws IOException {
rootDir = Jimfs.newFileSystem(Configuration.unix()).getPath("/tmp");
Files.createDirectory(rootDir);
Reported by PMD.
Line: 40
private Path rootDir;
@Override
public void setUp() throws IOException {
rootDir = Jimfs.newFileSystem(Configuration.unix()).getPath("/tmp");
Files.createDirectory(rootDir);
}
Reported by PMD.
Line: 42
@Override
public void setUp() throws IOException {
rootDir = Jimfs.newFileSystem(Configuration.unix()).getPath("/tmp");
Files.createDirectory(rootDir);
}
@Override
public void tearDown() throws IOException {
Reported by PMD.
Line: 46
Files.createDirectory(rootDir);
}
@Override
public void tearDown() throws IOException {
rootDir.getFileSystem().close();
}
public void testFileTraverser_emptyDirectory() throws Exception {
Reported by PMD.
Line: 48
@Override
public void tearDown() throws IOException {
rootDir.getFileSystem().close();
}
public void testFileTraverser_emptyDirectory() throws Exception {
assertThat(MoreFiles.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
}
Reported by PMD.
Line: 51
rootDir.getFileSystem().close();
}
public void testFileTraverser_emptyDirectory() throws Exception {
assertThat(MoreFiles.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
}
public void testFileTraverser_nonExistingFile() throws Exception {
Path file = rootDir.resolve("file-that-doesnt-exist");
Reported by PMD.
Line: 52
}
public void testFileTraverser_emptyDirectory() throws Exception {
assertThat(MoreFiles.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
}
public void testFileTraverser_nonExistingFile() throws Exception {
Path file = rootDir.resolve("file-that-doesnt-exist");
Reported by PMD.
Line: 52
}
public void testFileTraverser_emptyDirectory() throws Exception {
assertThat(MoreFiles.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
}
public void testFileTraverser_nonExistingFile() throws Exception {
Path file = rootDir.resolve("file-that-doesnt-exist");
Reported by PMD.
Line: 55
assertThat(MoreFiles.fileTraverser().breadthFirst(rootDir)).containsExactly(rootDir);
}
public void testFileTraverser_nonExistingFile() throws Exception {
Path file = rootDir.resolve("file-that-doesnt-exist");
assertThat(MoreFiles.fileTraverser().breadthFirst(file)).containsExactly(file);
}
Reported by PMD.
guava-tests/test/com/google/common/io/ByteSourceTester.java
32 issues
Line: 47
* @author Colin Decker
*/
@AndroidIncompatible // Android doesn't understand tests that lack default constructors.
public class ByteSourceTester extends SourceSinkTester<ByteSource, byte[], ByteSourceFactory> {
private static final ImmutableList<Method> testMethods = getTestMethods(ByteSourceTester.class);
static TestSuite tests(String name, ByteSourceFactory factory, boolean testAsCharSource) {
TestSuite suite = new TestSuite(name);
Reported by PMD.
Line: 59
} else {
suite.addTest(
suiteForBytes(
factory, entry.getValue().getBytes(Charsets.UTF_8), name, entry.getKey(), true));
}
}
return suite;
}
Reported by PMD.
Line: 79
ByteSourceFactory factory, byte[] bytes, String name, String desc, boolean slice) {
TestSuite suite = new TestSuite(name + " [" + desc + "]");
for (Method method : testMethods) {
suite.addTest(new ByteSourceTester(factory, bytes, name, desc, method));
}
if (slice && bytes.length > 0) {
// test a random slice() of the ByteSource
Random random = new Random();
Reported by PMD.
Line: 112
return suite;
}
private ByteSource source;
public ByteSourceTester(
ByteSourceFactory factory, byte[] bytes, String suiteName, String caseDesc, Method method) {
super(factory, bytes, suiteName, caseDesc, method);
}
Reported by PMD.
Line: 119
super(factory, bytes, suiteName, caseDesc, method);
}
@Override
public void setUp() throws IOException {
source = factory.createSource(data);
}
public void testOpenStream() throws IOException {
Reported by PMD.
Line: 124
source = factory.createSource(data);
}
public void testOpenStream() throws IOException {
InputStream in = source.openStream();
try {
byte[] readBytes = ByteStreams.toByteArray(in);
assertExpectedBytes(readBytes);
} finally {
Reported by PMD.
Line: 126
public void testOpenStream() throws IOException {
InputStream in = source.openStream();
try {
byte[] readBytes = ByteStreams.toByteArray(in);
assertExpectedBytes(readBytes);
} finally {
in.close();
}
Reported by PMD.
Line: 134
}
}
public void testOpenBufferedStream() throws IOException {
InputStream in = source.openBufferedStream();
try {
byte[] readBytes = ByteStreams.toByteArray(in);
assertExpectedBytes(readBytes);
} finally {
Reported by PMD.
Line: 136
public void testOpenBufferedStream() throws IOException {
InputStream in = source.openBufferedStream();
try {
byte[] readBytes = ByteStreams.toByteArray(in);
assertExpectedBytes(readBytes);
} finally {
in.close();
}
Reported by PMD.
Line: 144
}
}
public void testRead() throws IOException {
byte[] readBytes = source.read();
assertExpectedBytes(readBytes);
}
public void testCopyTo_outputStream() throws IOException {
Reported by PMD.