The following issues were found
guava/src/com/google/common/util/concurrent/ForwardingBlockingDeque.java
16 issues
Line: 50
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingBlockingDeque<E> extends ForwardingDeque<E>
implements BlockingDeque<E> {
/** Constructor for use by subclasses. */
protected ForwardingBlockingDeque() {}
@Override
Reported by PMD.
Line: 60
@Override
public int remainingCapacity() {
return delegate().remainingCapacity();
}
@Override
public void putFirst(E e) throws InterruptedException {
delegate().putFirst(e);
Reported by PMD.
Line: 65
@Override
public void putFirst(E e) throws InterruptedException {
delegate().putFirst(e);
}
@Override
public void putLast(E e) throws InterruptedException {
delegate().putLast(e);
Reported by PMD.
Line: 70
@Override
public void putLast(E e) throws InterruptedException {
delegate().putLast(e);
}
@Override
public boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offerFirst(e, timeout, unit);
Reported by PMD.
Line: 75
@Override
public boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offerFirst(e, timeout, unit);
}
@Override
public boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offerLast(e, timeout, unit);
Reported by PMD.
Line: 80
@Override
public boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offerLast(e, timeout, unit);
}
@Override
public E takeFirst() throws InterruptedException {
return delegate().takeFirst();
Reported by PMD.
Line: 85
@Override
public E takeFirst() throws InterruptedException {
return delegate().takeFirst();
}
@Override
public E takeLast() throws InterruptedException {
return delegate().takeLast();
Reported by PMD.
Line: 90
@Override
public E takeLast() throws InterruptedException {
return delegate().takeLast();
}
@Override
@CheckForNull
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException {
Reported by PMD.
Line: 96
@Override
@CheckForNull
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollFirst(timeout, unit);
}
@Override
@CheckForNull
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException {
Reported by PMD.
Line: 102
@Override
@CheckForNull
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollLast(timeout, unit);
}
@Override
public void put(E e) throws InterruptedException {
delegate().put(e);
Reported by PMD.
guava/src/com/google/common/collect/ForwardingBlockingDeque.java
16 issues
Line: 52
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingBlockingDeque<E> extends ForwardingDeque<E>
implements BlockingDeque<E> {
/** Constructor for use by subclasses. */
protected ForwardingBlockingDeque() {}
@Override
Reported by PMD.
Line: 62
@Override
public int remainingCapacity() {
return delegate().remainingCapacity();
}
@Override
public void putFirst(E e) throws InterruptedException {
delegate().putFirst(e);
Reported by PMD.
Line: 67
@Override
public void putFirst(E e) throws InterruptedException {
delegate().putFirst(e);
}
@Override
public void putLast(E e) throws InterruptedException {
delegate().putLast(e);
Reported by PMD.
Line: 72
@Override
public void putLast(E e) throws InterruptedException {
delegate().putLast(e);
}
@Override
public boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offerFirst(e, timeout, unit);
Reported by PMD.
Line: 77
@Override
public boolean offerFirst(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offerFirst(e, timeout, unit);
}
@Override
public boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offerLast(e, timeout, unit);
Reported by PMD.
Line: 82
@Override
public boolean offerLast(E e, long timeout, TimeUnit unit) throws InterruptedException {
return delegate().offerLast(e, timeout, unit);
}
@Override
public E takeFirst() throws InterruptedException {
return delegate().takeFirst();
Reported by PMD.
Line: 87
@Override
public E takeFirst() throws InterruptedException {
return delegate().takeFirst();
}
@Override
public E takeLast() throws InterruptedException {
return delegate().takeLast();
Reported by PMD.
Line: 92
@Override
public E takeLast() throws InterruptedException {
return delegate().takeLast();
}
@Override
@CheckForNull
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException {
Reported by PMD.
Line: 98
@Override
@CheckForNull
public E pollFirst(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollFirst(timeout, unit);
}
@Override
@CheckForNull
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException {
Reported by PMD.
Line: 104
@Override
@CheckForNull
public E pollLast(long timeout, TimeUnit unit) throws InterruptedException {
return delegate().pollLast(timeout, unit);
}
@Override
public void put(E e) throws InterruptedException {
delegate().put(e);
Reported by PMD.
guava/src/com/google/common/primitives/Booleans.java
16 issues
Line: 200
continue outer;
}
}
return i;
}
return -1;
}
/**
Reported by PMD.
Line: 46
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Booleans {
private Booleans() {}
/** Comparators for {@code Boolean} values. */
private enum BooleanComparator implements Comparator<Boolean> {
TRUE_FIRST(1, "Booleans.trueFirst()"),
Reported by PMD.
Line: 381
@GwtCompatible
private static class BooleanArrayAsList extends AbstractList<Boolean>
implements RandomAccess, Serializable {
final boolean[] array;
final int start;
final int end;
BooleanArrayAsList(boolean[] array) {
this(array, 0, array.length);
Reported by PMD.
Line: 382
private static class BooleanArrayAsList extends AbstractList<Boolean>
implements RandomAccess, Serializable {
final boolean[] array;
final int start;
final int end;
BooleanArrayAsList(boolean[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 383
implements RandomAccess, Serializable {
final boolean[] array;
final int start;
final int end;
BooleanArrayAsList(boolean[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 389
this(array, 0, array.length);
}
BooleanArrayAsList(boolean[] array, int start, int end) {
this.array = array;
this.start = start;
this.end = end;
}
Reported by PMD.
Line: 469
if (object instanceof BooleanArrayAsList) {
BooleanArrayAsList that = (BooleanArrayAsList) object;
int size = size();
if (that.size() != size) {
return false;
}
for (int i = 0; i < size; i++) {
if (array[start + i] != that.array[that.start + i]) {
return false;
Reported by PMD.
Line: 548
public static void reverse(boolean[] array, int fromIndex, int toIndex) {
checkNotNull(array);
checkPositionIndexes(fromIndex, toIndex, array.length);
for (int i = fromIndex, j = toIndex - 1; i < j; i++, j--) {
boolean tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
}
Reported by PMD.
Line: 186
* @param array the array to search for the sequence {@code target}
* @param target the array to search for as a sub-sequence of {@code array}
*/
public static int indexOf(boolean[] array, boolean[] target) {
checkNotNull(array, "array");
checkNotNull(target, "target");
if (target.length == 0) {
return 0;
}
Reported by PMD.
Line: 385
final int start;
final int end;
BooleanArrayAsList(boolean[] array) {
this(array, 0, array.length);
}
BooleanArrayAsList(boolean[] array, int start, int end) {
this.array = array;
Reported by PMD.
guava/src/com/google/common/util/concurrent/ListenerCallQueue.java
16 issues
Line: 177
isThreadScheduled = false;
}
// Log it and keep going.
logger.log(
Level.SEVERE,
"Exception while running callbacks for " + listener + " on " + executor,
e);
throw e;
}
Reported by PMD.
Line: 209
nextToRun.call(listener);
} catch (RuntimeException e) {
// Log it and keep going.
logger.log(
Level.SEVERE,
"Exception while executing callback: " + listener + " " + nextLabel,
e);
}
}
Reported by PMD.
Line: 62
private static final Logger logger = Logger.getLogger(ListenerCallQueue.class.getName());
// TODO(chrisn): promote AppendOnlyCollection for use here.
private final List<PerListenerQueue<L>> listeners =
Collections.synchronizedList(new ArrayList<PerListenerQueue<L>>());
/** Method reference-compatible listener event. */
interface Event<L> {
/** Call a method on the listener. */
Reported by PMD.
Line: 120
*/
public void dispatch() {
// iterate by index to avoid concurrent modification exceptions
for (int i = 0; i < listeners.size(); i++) {
listeners.get(i).dispatch();
}
}
/**
Reported by PMD.
Line: 121
public void dispatch() {
// iterate by index to avoid concurrent modification exceptions
for (int i = 0; i < listeners.size(); i++) {
listeners.get(i).dispatch();
}
}
/**
* A special purpose queue/executor that dispatches listener events serially on a configured
Reported by PMD.
Line: 133
* be added without necessarily executing immediately.
*/
private static final class PerListenerQueue<L> implements Runnable {
final L listener;
final Executor executor;
@GuardedBy("this")
final Queue<ListenerCallQueue.Event<L>> waitQueue = Queues.newArrayDeque();
Reported by PMD.
Line: 134
*/
private static final class PerListenerQueue<L> implements Runnable {
final L listener;
final Executor executor;
@GuardedBy("this")
final Queue<ListenerCallQueue.Event<L>> waitQueue = Queues.newArrayDeque();
@GuardedBy("this")
Reported by PMD.
Line: 137
final Executor executor;
@GuardedBy("this")
final Queue<ListenerCallQueue.Event<L>> waitQueue = Queues.newArrayDeque();
@GuardedBy("this")
final Queue<Object> labelQueue = Queues.newArrayDeque();
@GuardedBy("this")
Reported by PMD.
Line: 140
final Queue<ListenerCallQueue.Event<L>> waitQueue = Queues.newArrayDeque();
@GuardedBy("this")
final Queue<Object> labelQueue = Queues.newArrayDeque();
@GuardedBy("this")
boolean isThreadScheduled;
PerListenerQueue(L listener, Executor executor) {
Reported by PMD.
Line: 143
final Queue<Object> labelQueue = Queues.newArrayDeque();
@GuardedBy("this")
boolean isThreadScheduled;
PerListenerQueue(L listener, Executor executor) {
this.listener = checkNotNull(listener);
this.executor = checkNotNull(executor);
}
Reported by PMD.
guava/src/com/google/common/primitives/Chars.java
16 issues
Line: 183
continue outer;
}
}
return i;
}
return -1;
}
/**
Reported by PMD.
Line: 50
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Chars {
private Chars() {}
/**
* The number of bytes required to represent a primitive {@code char} value.
*
Reported by PMD.
Line: 50
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Chars {
private Chars() {}
/**
* The number of bytes required to represent a primitive {@code char} value.
*
Reported by PMD.
Line: 484
public static void reverse(char[] array, int fromIndex, int toIndex) {
checkNotNull(array);
checkPositionIndexes(fromIndex, toIndex, array.length);
for (int i = fromIndex, j = toIndex - 1; i < j; i++, j--) {
char tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
}
Reported by PMD.
Line: 513
@GwtCompatible
private static class CharArrayAsList extends AbstractList<Character>
implements RandomAccess, Serializable {
final char[] array;
final int start;
final int end;
CharArrayAsList(char[] array) {
this(array, 0, array.length);
Reported by PMD.
Line: 514
private static class CharArrayAsList extends AbstractList<Character>
implements RandomAccess, Serializable {
final char[] array;
final int start;
final int end;
CharArrayAsList(char[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 515
implements RandomAccess, Serializable {
final char[] array;
final int start;
final int end;
CharArrayAsList(char[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 521
this(array, 0, array.length);
}
CharArrayAsList(char[] array, int start, int end) {
this.array = array;
this.start = start;
this.end = end;
}
Reported by PMD.
Line: 601
if (object instanceof CharArrayAsList) {
CharArrayAsList that = (CharArrayAsList) object;
int size = size();
if (that.size() != size) {
return false;
}
for (int i = 0; i < size; i++) {
if (array[start + i] != that.array[that.start + i]) {
return false;
Reported by PMD.
Line: 169
* @param array the array to search for the sequence {@code target}
* @param target the array to search for as a sub-sequence of {@code array}
*/
public static int indexOf(char[] array, char[] target) {
checkNotNull(array, "array");
checkNotNull(target, "target");
if (target.length == 0) {
return 0;
}
Reported by PMD.
guava/src/com/google/common/math/StatsAccumulator.java
16 issues
Line: 41
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class StatsAccumulator {
// These fields must satisfy the requirements of Stats' constructor as well as those of the stat
// methods of this class.
private long count = 0;
private double mean = 0.0; // any finite value will do, we only use it to multiply by zero for sum
Reported by PMD.
Line: 45
// These fields must satisfy the requirements of Stats' constructor as well as those of the stat
// methods of this class.
private long count = 0;
private double mean = 0.0; // any finite value will do, we only use it to multiply by zero for sum
private double sumOfSquaresOfDeltas = 0.0;
private double min = NaN; // any value will do
private double max = NaN; // any value will do
Reported by PMD.
Line: 45
// These fields must satisfy the requirements of Stats' constructor as well as those of the stat
// methods of this class.
private long count = 0;
private double mean = 0.0; // any finite value will do, we only use it to multiply by zero for sum
private double sumOfSquaresOfDeltas = 0.0;
private double min = NaN; // any value will do
private double max = NaN; // any value will do
Reported by PMD.
Line: 45
// These fields must satisfy the requirements of Stats' constructor as well as those of the stat
// methods of this class.
private long count = 0;
private double mean = 0.0; // any finite value will do, we only use it to multiply by zero for sum
private double sumOfSquaresOfDeltas = 0.0;
private double min = NaN; // any value will do
private double max = NaN; // any value will do
Reported by PMD.
Line: 46
// These fields must satisfy the requirements of Stats' constructor as well as those of the stat
// methods of this class.
private long count = 0;
private double mean = 0.0; // any finite value will do, we only use it to multiply by zero for sum
private double sumOfSquaresOfDeltas = 0.0;
private double min = NaN; // any value will do
private double max = NaN; // any value will do
/** Adds the given value to the dataset. */
Reported by PMD.
Line: 46
// These fields must satisfy the requirements of Stats' constructor as well as those of the stat
// methods of this class.
private long count = 0;
private double mean = 0.0; // any finite value will do, we only use it to multiply by zero for sum
private double sumOfSquaresOfDeltas = 0.0;
private double min = NaN; // any value will do
private double max = NaN; // any value will do
/** Adds the given value to the dataset. */
Reported by PMD.
Line: 46
// These fields must satisfy the requirements of Stats' constructor as well as those of the stat
// methods of this class.
private long count = 0;
private double mean = 0.0; // any finite value will do, we only use it to multiply by zero for sum
private double sumOfSquaresOfDeltas = 0.0;
private double min = NaN; // any value will do
private double max = NaN; // any value will do
/** Adds the given value to the dataset. */
Reported by PMD.
Line: 47
// methods of this class.
private long count = 0;
private double mean = 0.0; // any finite value will do, we only use it to multiply by zero for sum
private double sumOfSquaresOfDeltas = 0.0;
private double min = NaN; // any value will do
private double max = NaN; // any value will do
/** Adds the given value to the dataset. */
public void add(double value) {
Reported by PMD.
Line: 47
// methods of this class.
private long count = 0;
private double mean = 0.0; // any finite value will do, we only use it to multiply by zero for sum
private double sumOfSquaresOfDeltas = 0.0;
private double min = NaN; // any value will do
private double max = NaN; // any value will do
/** Adds the given value to the dataset. */
public void add(double value) {
Reported by PMD.
Line: 47
// methods of this class.
private long count = 0;
private double mean = 0.0; // any finite value will do, we only use it to multiply by zero for sum
private double sumOfSquaresOfDeltas = 0.0;
private double min = NaN; // any value will do
private double max = NaN; // any value will do
/** Adds the given value to the dataset. */
public void add(double value) {
Reported by PMD.
guava/src/com/google/common/collect/ContiguousSet.java
16 issues
Line: 54
@GwtCompatible(emulated = true)
@SuppressWarnings("rawtypes") // allow ungenerified Comparable types
@ElementTypesAreNonnullByDefault
public abstract class ContiguousSet<C extends Comparable> extends ImmutableSortedSet<C> {
/**
* Returns a {@code ContiguousSet} containing the same values in the given domain {@linkplain
* Range#contains contained} by the range.
*
* @throws IllegalArgumentException if neither range nor the domain has a lower bound, or if
Reported by PMD.
Line: 54
@GwtCompatible(emulated = true)
@SuppressWarnings("rawtypes") // allow ungenerified Comparable types
@ElementTypesAreNonnullByDefault
public abstract class ContiguousSet<C extends Comparable> extends ImmutableSortedSet<C> {
/**
* Returns a {@code ContiguousSet} containing the same values in the given domain {@linkplain
* Range#contains contained} by the range.
*
* @throws IllegalArgumentException if neither range nor the domain has a lower bound, or if
Reported by PMD.
Line: 80
}
boolean empty;
if (effectiveRange.isEmpty()) {
empty = true;
} else {
/*
* requireNonNull is safe because the effectiveRange operations above would have thrown or
* effectiveRange.isEmpty() would have returned true.
Reported by PMD.
Line: 87
* requireNonNull is safe because the effectiveRange operations above would have thrown or
* effectiveRange.isEmpty() would have returned true.
*/
C afterLower = requireNonNull(range.lowerBound.leastValueAbove(domain));
C beforeUpper = requireNonNull(range.upperBound.greatestValueBelow(domain));
// Per class spec, we are allowed to throw CCE if necessary
empty = Range.compareOrThrow(afterLower, beforeUpper) > 0;
}
Reported by PMD.
Line: 88
* effectiveRange.isEmpty() would have returned true.
*/
C afterLower = requireNonNull(range.lowerBound.leastValueAbove(domain));
C beforeUpper = requireNonNull(range.upperBound.greatestValueBelow(domain));
// Per class spec, we are allowed to throw CCE if necessary
empty = Range.compareOrThrow(afterLower, beforeUpper) > 0;
}
return empty
Reported by PMD.
Line: 150
return create(Range.closedOpen(lower, upper), DiscreteDomain.longs());
}
final DiscreteDomain<C> domain;
ContiguousSet(DiscreteDomain<C> domain) {
super(Ordering.natural());
this.domain = domain;
}
Reported by PMD.
Line: 173
public ContiguousSet<C> subSet(C fromElement, C toElement) {
checkNotNull(fromElement);
checkNotNull(toElement);
checkArgument(comparator().compare(fromElement, toElement) <= 0);
return subSetImpl(fromElement, true, toElement, false);
}
/** @since 12.0 */
@GwtIncompatible // NavigableSet
Reported by PMD.
Line: 184
C fromElement, boolean fromInclusive, C toElement, boolean toInclusive) {
checkNotNull(fromElement);
checkNotNull(toElement);
checkArgument(comparator().compare(fromElement, toElement) <= 0);
return subSetImpl(fromElement, fromInclusive, toElement, toInclusive);
}
@Override
public ContiguousSet<C> tailSet(C fromElement) {
Reported by PMD.
Line: 204
* These methods perform most headSet, subSet, and tailSet logic, besides parameter validation.
*/
@SuppressWarnings("MissingOverride") // Supermethod does not exist under GWT.
abstract ContiguousSet<C> headSetImpl(C toElement, boolean inclusive);
@SuppressWarnings("MissingOverride") // Supermethod does not exist under GWT.
abstract ContiguousSet<C> subSetImpl(
C fromElement, boolean fromInclusive, C toElement, boolean toInclusive);
Reported by PMD.
Line: 207
abstract ContiguousSet<C> headSetImpl(C toElement, boolean inclusive);
@SuppressWarnings("MissingOverride") // Supermethod does not exist under GWT.
abstract ContiguousSet<C> subSetImpl(
C fromElement, boolean fromInclusive, C toElement, boolean toInclusive);
@SuppressWarnings("MissingOverride") // Supermethod does not exist under GWT.
abstract ContiguousSet<C> tailSetImpl(C fromElement, boolean inclusive);
Reported by PMD.
guava-tests/test/com/google/common/primitives/ShortArrayAsListTest.java
16 issues
Line: 45
private static List<Short> asList(Short[] values) {
short[] temp = new short[values.length];
for (short i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
}
return Shorts.asList(temp);
}
Reported by PMD.
Line: 131
@Override
public List<Short> create(Object... elements) {
Short[] array = new Short[elements.length];
short i = 0;
for (Object e : elements) {
array[i++] = (Short) e;
}
return create(array);
}
Reported by PMD.
Line: 41
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class ShortArrayAsListTest extends TestCase {
private static List<Short> asList(Short[] values) {
short[] temp = new short[values.length];
for (short i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
Reported by PMD.
Line: 51
return Shorts.asList(temp);
}
@GwtIncompatible // suite
public static Test suite() {
List<ListTestSuiteBuilder<Short>> builders =
ImmutableList.of(
ListTestSuiteBuilder.using(new ShortsAsListGenerator()).named("Shorts.asList"),
ListTestSuiteBuilder.using(new ShortsAsListHeadSubListGenerator())
Reported by PMD.
Line: 66
TestSuite suite = new TestSuite();
for (ListTestSuiteBuilder<Short> builder : builders) {
suite.addTest(
builder
.withFeatures(
CollectionSize.ONE,
CollectionSize.SEVERAL,
CollectionFeature.RESTRICTS_ELEMENTS,
ListFeature.SUPPORTS_SET)
Reported by PMD.
Line: 92
protected List<Short> create(Short[] elements) {
Short[] suffix = {Short.MIN_VALUE, Short.MAX_VALUE};
Short[] all = concat(elements, suffix);
return asList(all).subList(0, elements.length);
}
}
public static final class ShortsAsListTailSubListGenerator extends TestShortListGenerator {
@Override
Reported by PMD.
Line: 101
protected List<Short> create(Short[] elements) {
Short[] prefix = {(short) 86, (short) 99};
Short[] all = concat(prefix, elements);
return asList(all).subList(2, elements.length + 2);
}
}
public static final class ShortsAsListMiddleSubListGenerator extends TestShortListGenerator {
@Override
Reported by PMD.
Line: 111
Short[] prefix = {Short.MIN_VALUE, Short.MAX_VALUE};
Short[] suffix = {(short) 86, (short) 99};
Short[] all = concat(concat(prefix, elements), suffix);
return asList(all).subList(2, elements.length + 2);
}
}
private static Short[] concat(Short[] left, Short[] right) {
Short[] result = new Short[left.length + right.length];
Reported by PMD.
Line: 43
@GwtCompatible(emulated = true)
public class ShortArrayAsListTest extends TestCase {
private static List<Short> asList(Short[] values) {
short[] temp = new short[values.length];
for (short i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
}
return Shorts.asList(temp);
Reported by PMD.
Line: 115
}
}
private static Short[] concat(Short[] left, Short[] right) {
Short[] result = new Short[left.length + right.length];
System.arraycopy(left, 0, result, 0, left.length);
System.arraycopy(right, 0, result, left.length, right.length);
return result;
}
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/FakeTimeLimiterTest.java
16 issues
Line: 36
private static final int DELAY_MS = 50;
private static final String RETURN_VALUE = "abc";
private TimeLimiter timeLimiter;
@Override
protected void setUp() throws Exception {
super.setUp();
timeLimiter = new FakeTimeLimiter();
Reported by PMD.
Line: 38
private TimeLimiter timeLimiter;
@Override
protected void setUp() throws Exception {
super.setUp();
timeLimiter = new FakeTimeLimiter();
}
Reported by PMD.
Line: 44
timeLimiter = new FakeTimeLimiter();
}
public void testCallWithTimeout_propagatesReturnValue() throws Exception {
String result =
timeLimiter.callWithTimeout(
Callables.returning(RETURN_VALUE), DELAY_MS, TimeUnit.MILLISECONDS);
assertThat(result).isEqualTo(RETURN_VALUE);
Reported by PMD.
Line: 49
timeLimiter.callWithTimeout(
Callables.returning(RETURN_VALUE), DELAY_MS, TimeUnit.MILLISECONDS);
assertThat(result).isEqualTo(RETURN_VALUE);
}
public void testCallWithTimeout_wrapsCheckedException() throws Exception {
Exception exception = new SampleCheckedException();
try {
Reported by PMD.
Line: 52
assertThat(result).isEqualTo(RETURN_VALUE);
}
public void testCallWithTimeout_wrapsCheckedException() throws Exception {
Exception exception = new SampleCheckedException();
try {
timeLimiter.callWithTimeout(callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
fail("Expected ExecutionException");
} catch (ExecutionException e) {
Reported by PMD.
Line: 58
timeLimiter.callWithTimeout(callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
fail("Expected ExecutionException");
} catch (ExecutionException e) {
assertThat(e.getCause()).isEqualTo(exception);
}
}
public void testCallWithTimeout_wrapsUncheckedException() throws Exception {
Exception exception = new RuntimeException("test");
Reported by PMD.
Line: 62
}
}
public void testCallWithTimeout_wrapsUncheckedException() throws Exception {
Exception exception = new RuntimeException("test");
try {
timeLimiter.callWithTimeout(callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
fail("Expected UncheckedExecutionException");
} catch (UncheckedExecutionException e) {
Reported by PMD.
Line: 68
timeLimiter.callWithTimeout(callableThrowing(exception), DELAY_MS, TimeUnit.MILLISECONDS);
fail("Expected UncheckedExecutionException");
} catch (UncheckedExecutionException e) {
assertThat(e.getCause()).isEqualTo(exception);
}
}
public void testCallUninterruptiblyWithTimeout_propagatesReturnValue() throws Exception {
String result =
Reported by PMD.
Line: 72
}
}
public void testCallUninterruptiblyWithTimeout_propagatesReturnValue() throws Exception {
String result =
timeLimiter.callUninterruptiblyWithTimeout(
Callables.returning(RETURN_VALUE), DELAY_MS, TimeUnit.MILLISECONDS);
assertThat(result).isEqualTo(RETURN_VALUE);
Reported by PMD.
Line: 77
timeLimiter.callUninterruptiblyWithTimeout(
Callables.returning(RETURN_VALUE), DELAY_MS, TimeUnit.MILLISECONDS);
assertThat(result).isEqualTo(RETURN_VALUE);
}
public void testRunWithTimeout_returnsWithoutException() throws Exception {
timeLimiter.runWithTimeout(Runnables.doNothing(), DELAY_MS, TimeUnit.MILLISECONDS);
}
Reported by PMD.
guava/src/com/google/common/collect/ForwardingCollection.java
16 issues
Line: 52
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class ForwardingCollection<E extends @Nullable Object> extends ForwardingObject
implements Collection<E> {
// TODO(lowasser): identify places where thread safety is actually lost
/** Constructor for use by subclasses. */
protected ForwardingCollection() {}
Reported by PMD.
Line: 63
@Override
public Iterator<E> iterator() {
return delegate().iterator();
}
@Override
public int size() {
return delegate().size();
Reported by PMD.
Line: 68
@Override
public int size() {
return delegate().size();
}
@CanIgnoreReturnValue
@Override
public boolean removeAll(Collection<?> collection) {
Reported by PMD.
Line: 74
@CanIgnoreReturnValue
@Override
public boolean removeAll(Collection<?> collection) {
return delegate().removeAll(collection);
}
@Override
public boolean isEmpty() {
return delegate().isEmpty();
Reported by PMD.
Line: 79
@Override
public boolean isEmpty() {
return delegate().isEmpty();
}
@Override
public boolean contains(@CheckForNull Object object) {
return delegate().contains(object);
Reported by PMD.
Line: 84
@Override
public boolean contains(@CheckForNull Object object) {
return delegate().contains(object);
}
@CanIgnoreReturnValue
@Override
public boolean add(@ParametricNullness E element) {
Reported by PMD.
Line: 90
@CanIgnoreReturnValue
@Override
public boolean add(@ParametricNullness E element) {
return delegate().add(element);
}
@CanIgnoreReturnValue
@Override
public boolean remove(@CheckForNull Object object) {
Reported by PMD.
Line: 96
@CanIgnoreReturnValue
@Override
public boolean remove(@CheckForNull Object object) {
return delegate().remove(object);
}
@Override
public boolean containsAll(Collection<?> collection) {
return delegate().containsAll(collection);
Reported by PMD.
Line: 101
@Override
public boolean containsAll(Collection<?> collection) {
return delegate().containsAll(collection);
}
@CanIgnoreReturnValue
@Override
public boolean addAll(Collection<? extends E> collection) {
Reported by PMD.
Line: 107
@CanIgnoreReturnValue
@Override
public boolean addAll(Collection<? extends E> collection) {
return delegate().addAll(collection);
}
@CanIgnoreReturnValue
@Override
public boolean retainAll(Collection<?> collection) {
Reported by PMD.