The following issues were found
android/guava/src/com/google/common/reflect/Parameter.java
11 issues
Line: 37
@ElementTypesAreNonnullByDefault
public final class Parameter implements AnnotatedElement {
private final Invokable<?, ?> declaration;
private final int position;
private final TypeToken<?> type;
private final ImmutableList<Annotation> annotations;
Parameter(
Reported by PMD.
Line: 38
public final class Parameter implements AnnotatedElement {
private final Invokable<?, ?> declaration;
private final int position;
private final TypeToken<?> type;
private final ImmutableList<Annotation> annotations;
Parameter(
Invokable<?, ?> declaration, int position, TypeToken<?> type, Annotation[] annotations) {
Reported by PMD.
Line: 84
/** @since 18.0 */
// @Override on JDK8
public <A extends Annotation> A[] getAnnotationsByType(Class<A> annotationType) {
return getDeclaredAnnotationsByType(annotationType);
}
/** @since 18.0 */
// @Override on JDK8
Reported by PMD.
Line: 98
/** @since 18.0 */
// @Override on JDK8
@CheckForNull
public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationType) {
checkNotNull(annotationType);
return FluentIterable.from(annotations).filter(annotationType).first().orNull();
}
/** @since 18.0 */
Reported by PMD.
Line: 100
@CheckForNull
public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationType) {
checkNotNull(annotationType);
return FluentIterable.from(annotations).filter(annotationType).first().orNull();
}
/** @since 18.0 */
// @Override on JDK8
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType) {
Reported by PMD.
Line: 100
@CheckForNull
public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationType) {
checkNotNull(annotationType);
return FluentIterable.from(annotations).filter(annotationType).first().orNull();
}
/** @since 18.0 */
// @Override on JDK8
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType) {
Reported by PMD.
Line: 100
@CheckForNull
public <A extends Annotation> A getDeclaredAnnotation(Class<A> annotationType) {
checkNotNull(annotationType);
return FluentIterable.from(annotations).filter(annotationType).first().orNull();
}
/** @since 18.0 */
// @Override on JDK8
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType) {
Reported by PMD.
Line: 105
/** @since 18.0 */
// @Override on JDK8
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType) {
@Nullable
A[] result = FluentIterable.from(annotations).filter(annotationType).toArray(annotationType);
@SuppressWarnings("nullness") // safe because the input list contains no nulls
A[] cast = (A[]) result;
return cast;
Reported by PMD.
Line: 107
// @Override on JDK8
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType) {
@Nullable
A[] result = FluentIterable.from(annotations).filter(annotationType).toArray(annotationType);
@SuppressWarnings("nullness") // safe because the input list contains no nulls
A[] cast = (A[]) result;
return cast;
}
Reported by PMD.
Line: 107
// @Override on JDK8
public <A extends Annotation> A[] getDeclaredAnnotationsByType(Class<A> annotationType) {
@Nullable
A[] result = FluentIterable.from(annotations).filter(annotationType).toArray(annotationType);
@SuppressWarnings("nullness") // safe because the input list contains no nulls
A[] cast = (A[]) result;
return cast;
}
Reported by PMD.
android/guava/src/com/google/common/collect/ForwardingSortedMap.java
11 issues
Line: 69
@Override
@CheckForNull
public Comparator<? super K> comparator() {
return delegate().comparator();
}
@Override
@ParametricNullness
public K firstKey() {
Reported by PMD.
Line: 75
@Override
@ParametricNullness
public K firstKey() {
return delegate().firstKey();
}
@Override
public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
return delegate().headMap(toKey);
Reported by PMD.
Line: 80
@Override
public SortedMap<K, V> headMap(@ParametricNullness K toKey) {
return delegate().headMap(toKey);
}
@Override
@ParametricNullness
public K lastKey() {
Reported by PMD.
Line: 86
@Override
@ParametricNullness
public K lastKey() {
return delegate().lastKey();
}
@Override
public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
return delegate().subMap(fromKey, toKey);
Reported by PMD.
Line: 91
@Override
public SortedMap<K, V> subMap(@ParametricNullness K fromKey, @ParametricNullness K toKey) {
return delegate().subMap(fromKey, toKey);
}
@Override
public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
return delegate().tailMap(fromKey);
Reported by PMD.
Line: 96
@Override
public SortedMap<K, V> tailMap(@ParametricNullness K fromKey) {
return delegate().tailMap(fromKey);
}
/**
* A sensible implementation of {@link SortedMap#keySet} in terms of the methods of {@code
* ForwardingSortedMap}. In many cases, you may wish to override {@link
Reported by PMD.
Line: 139
// any CCE or NPE will be caught
@SuppressWarnings({"unchecked", "nullness"})
SortedMap<@Nullable Object, V> self = (SortedMap<@Nullable Object, V>) this;
Object ceilingKey = self.tailMap(key).firstKey();
return unsafeCompare(comparator(), ceilingKey, key) == 0;
} catch (ClassCastException | NoSuchElementException | NullPointerException e) {
return false;
}
}
Reported by PMD.
Line: 139
// any CCE or NPE will be caught
@SuppressWarnings({"unchecked", "nullness"})
SortedMap<@Nullable Object, V> self = (SortedMap<@Nullable Object, V>) this;
Object ceilingKey = self.tailMap(key).firstKey();
return unsafeCompare(comparator(), ceilingKey, key) == 0;
} catch (ClassCastException | NoSuchElementException | NullPointerException e) {
return false;
}
}
Reported by PMD.
Line: 141
SortedMap<@Nullable Object, V> self = (SortedMap<@Nullable Object, V>) this;
Object ceilingKey = self.tailMap(key).firstKey();
return unsafeCompare(comparator(), ceilingKey, key) == 0;
} catch (ClassCastException | NoSuchElementException | NullPointerException e) {
return false;
}
}
/**
Reported by PMD.
Line: 141
SortedMap<@Nullable Object, V> self = (SortedMap<@Nullable Object, V>) this;
Object ceilingKey = self.tailMap(key).firstKey();
return unsafeCompare(comparator(), ceilingKey, key) == 0;
} catch (ClassCastException | NoSuchElementException | NullPointerException e) {
return false;
}
}
/**
Reported by PMD.
guava-gwt/src-super/com/google/common/collect/super/com/google/common/collect/ImmutableSet.java
11 issues
Line: 40
* @author Hayward Chan
*/
@SuppressWarnings("serial") // Serialization only done in GWT.
public abstract class ImmutableSet<E> extends ImmutableCollection<E> implements Set<E> {
ImmutableSet() {}
public static <E> Collector<E, ?, ImmutableSet<E>> toImmutableSet() {
return CollectCollectors.toImmutableSet();
}
Reported by PMD.
Line: 48
}
// Casting to any type is safe because the set will never hold any elements.
@SuppressWarnings({"unchecked"})
public static <E> ImmutableSet<E> of() {
return (ImmutableSet<E>) RegularImmutableSet.EMPTY;
}
public static <E> ImmutableSet<E> of(E element) {
Reported by PMD.
Line: 123
}
Set<E> delegate = Sets.newLinkedHashSet();
delegate.add(checkNotNull(first));
do {
delegate.add(checkNotNull(elements.next()));
} while (elements.hasNext());
return unsafeDelegate(delegate);
Reported by PMD.
Line: 138
case 0:
return of();
case 1:
return new SingletonImmutableSet<E>(delegate.iterator().next());
default:
return new RegularImmutableSet<E>(delegate);
}
}
Reported by PMD.
Line: 156
case 0:
return of();
case 1:
return new SingletonImmutableSet<E>(set.iterator().next());
default:
return new RegularImmutableSet<E>(set);
}
}
Reported by PMD.
Line: 182
@Override
public UnmodifiableIterator<E> iterator() {
return asList().iterator();
}
@Override
ImmutableList<E> createAsList() {
return new ImmutableAsList<E>() {
Reported by PMD.
Line: 190
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: 190
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: 211
public static class Builder<E> extends ImmutableCollection.Builder<E> {
// accessed directly by ImmutableSortedSet
final ArrayList<E> contents;
public Builder() {
this.contents = Lists.newArrayList();
}
Reported by PMD.
Line: 239
public Builder<E> addAll(Iterable<? extends E> elements) {
if (elements instanceof Collection) {
Collection<?> collection = (Collection<?>) elements;
contents.ensureCapacity(contents.size() + collection.size());
}
super.addAll(elements);
return this;
}
Reported by PMD.
android/guava/src/com/google/common/primitives/Bytes.java
11 issues
Line: 126
continue outer;
}
}
return i;
}
return -1;
}
/**
Reported by PMD.
Line: 48
// javadoc?
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class Bytes {
private Bytes() {}
/**
* Returns a hash code for {@code value}; equal to the result of invoking {@code ((Byte)
* value).hashCode()}.
Reported by PMD.
Line: 243
@GwtCompatible
private static class ByteArrayAsList extends AbstractList<Byte>
implements RandomAccess, Serializable {
final byte[] array;
final int start;
final int end;
ByteArrayAsList(byte[] array) {
this(array, 0, array.length);
Reported by PMD.
Line: 244
private static class ByteArrayAsList extends AbstractList<Byte>
implements RandomAccess, Serializable {
final byte[] array;
final int start;
final int end;
ByteArrayAsList(byte[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 245
implements RandomAccess, Serializable {
final byte[] array;
final int start;
final int end;
ByteArrayAsList(byte[] array) {
this(array, 0, array.length);
}
Reported by PMD.
Line: 251
this(array, 0, array.length);
}
ByteArrayAsList(byte[] array, int start, int end) {
this.array = array;
this.start = start;
this.end = end;
}
Reported by PMD.
Line: 330
if (object instanceof ByteArrayAsList) {
ByteArrayAsList that = (ByteArrayAsList) 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: 393
public static void reverse(byte[] array, int fromIndex, int toIndex) {
checkNotNull(array);
checkPositionIndexes(fromIndex, toIndex, array.length);
for (int i = fromIndex, j = toIndex - 1; i < j; i++, j--) {
byte tmp = array[i];
array[i] = array[j];
array[j] = tmp;
}
}
Reported by PMD.
Line: 166
length += array.length;
}
byte[] result = new byte[length];
int pos = 0;
for (byte[] array : arrays) {
System.arraycopy(array, 0, result, pos, array.length);
pos += array.length;
}
return result;
Reported by PMD.
Line: 213
Object[] boxedArray = collection.toArray();
int len = boxedArray.length;
byte[] array = new byte[len];
for (int i = 0; i < len; i++) {
// checkNotNull for GWT (do not optimize)
array[i] = ((Number) checkNotNull(boxedArray[i])).byteValue();
}
return array;
Reported by PMD.
android/guava-tests/test/com/google/common/primitives/ByteArrayAsListTest.java
11 issues
Line: 41
* @author Kevin Bourrillion
*/
@GwtCompatible(emulated = true)
public class ByteArrayAsListTest extends TestCase {
private static List<Byte> asList(Byte[] values) {
byte[] temp = new byte[values.length];
for (int i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
Reported by PMD.
Line: 51
return Bytes.asList(temp);
}
@GwtIncompatible // suite
public static Test suite() {
List<ListTestSuiteBuilder<Byte>> builders =
ImmutableList.of(
ListTestSuiteBuilder.using(new BytesAsListGenerator()).named("Bytes.asList"),
ListTestSuiteBuilder.using(new BytesAsListHeadSubListGenerator())
Reported by PMD.
Line: 66
TestSuite suite = new TestSuite();
for (ListTestSuiteBuilder<Byte> builder : builders) {
suite.addTest(
builder
.withFeatures(
CollectionSize.ONE,
CollectionSize.SEVERAL,
CollectionFeature.RESTRICTS_ELEMENTS,
ListFeature.SUPPORTS_SET)
Reported by PMD.
Line: 92
protected List<Byte> create(Byte[] elements) {
Byte[] suffix = {Byte.MIN_VALUE, Byte.MAX_VALUE};
Byte[] all = concat(elements, suffix);
return asList(all).subList(0, elements.length);
}
}
public static final class BytesAsListTailSubListGenerator extends TestByteListGenerator {
@Override
Reported by PMD.
Line: 101
protected List<Byte> create(Byte[] elements) {
Byte[] prefix = {(byte) 86, (byte) 99};
Byte[] all = concat(prefix, elements);
return asList(all).subList(2, elements.length + 2);
}
}
public static final class BytesAsListMiddleSubListGenerator extends TestByteListGenerator {
@Override
Reported by PMD.
Line: 111
Byte[] prefix = {Byte.MIN_VALUE, Byte.MAX_VALUE};
Byte[] suffix = {(byte) 86, (byte) 99};
Byte[] all = concat(concat(prefix, elements), suffix);
return asList(all).subList(2, elements.length + 2);
}
}
private static Byte[] concat(Byte[] left, Byte[] right) {
Byte[] result = new Byte[left.length + right.length];
Reported by PMD.
Line: 44
public class ByteArrayAsListTest extends TestCase {
private static List<Byte> asList(Byte[] values) {
byte[] temp = new byte[values.length];
for (int i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
}
return Bytes.asList(temp);
}
Reported by PMD.
Line: 46
private static List<Byte> asList(Byte[] values) {
byte[] temp = new byte[values.length];
for (int i = 0; i < values.length; i++) {
temp[i] = checkNotNull(values[i]); // checkNotNull for GWT (do not optimize).
}
return Bytes.asList(temp);
}
@GwtIncompatible // suite
Reported by PMD.
Line: 130
@Override
public List<Byte> create(Object... elements) {
Byte[] array = new Byte[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (Byte) e;
}
return create(array);
Reported by PMD.
Line: 131
@Override
public List<Byte> create(Object... elements) {
Byte[] array = new Byte[elements.length];
int i = 0;
for (Object e : elements) {
array[i++] = (Byte) e;
}
return create(array);
}
Reported by PMD.
android/guava/src/com/google/common/hash/MacHashFunction.java
11 issues
Line: 37
final class MacHashFunction extends AbstractHashFunction {
@SuppressWarnings("Immutable") // cloned before each use
private final Mac prototype;
@SuppressWarnings("Immutable") // keys are immutable, but not provably so
private final Key key;
private final String toString;
Reported by PMD.
Line: 40
private final Mac prototype;
@SuppressWarnings("Immutable") // keys are immutable, but not provably so
private final Key key;
private final String toString;
private final int bits;
private final boolean supportsClone;
Reported by PMD.
Line: 42
@SuppressWarnings("Immutable") // keys are immutable, but not provably so
private final Key key;
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
Reported by PMD.
Line: 42
@SuppressWarnings("Immutable") // keys are immutable, but not provably so
private final Key key;
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
Reported by PMD.
Line: 43
private final Key key;
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
this.key = checkNotNull(key);
Reported by PMD.
Line: 43
private final Key key;
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
this.key = checkNotNull(key);
Reported by PMD.
Line: 44
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
this.key = checkNotNull(key);
this.toString = checkNotNull(toString);
Reported by PMD.
Line: 44
private final String toString;
private final int bits;
private final boolean supportsClone;
MacHashFunction(String algorithmName, Key key, String toString) {
this.prototype = getMac(algorithmName, key);
this.key = checkNotNull(key);
this.toString = checkNotNull(toString);
Reported by PMD.
Line: 71
private static Mac getMac(String algorithmName, Key key) {
try {
Mac mac = Mac.getInstance(algorithmName);
mac.init(key);
return mac;
} catch (NoSuchAlgorithmException e) {
throw new IllegalStateException(e);
} catch (InvalidKeyException e) {
throw new IllegalArgumentException(e);
Reported by PMD.
Line: 99
/** Hasher that updates a {@link Mac} (message authentication code). */
private static final class MacHasher extends AbstractByteHasher {
private final Mac mac;
private boolean done;
private MacHasher(Mac mac) {
this.mac = mac;
}
Reported by PMD.
android/guava/src/com/google/common/collect/EnumMultiset.java
11 issues
Line: 49
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class EnumMultiset<E extends Enum<E>> extends AbstractMultiset<E>
implements Serializable {
/** Creates an empty {@code EnumMultiset}. */
public static <E extends Enum<E>> EnumMultiset<E> create(Class<E> type) {
return new EnumMultiset<E>(type);
}
Reported by PMD.
Line: 66
public static <E extends Enum<E>> EnumMultiset<E> create(Iterable<E> elements) {
Iterator<E> iterator = elements.iterator();
checkArgument(iterator.hasNext(), "EnumMultiset constructor passed empty Iterable");
EnumMultiset<E> multiset = new EnumMultiset<>(iterator.next().getDeclaringClass());
Iterables.addAll(multiset, elements);
return multiset;
}
/**
Reported by PMD.
Line: 86
private transient Class<E> type;
private transient E[] enumConstants;
private transient int[] counts;
private transient int distinctElements;
private transient long size;
/** Creates an empty {@code EnumMultiset}. */
private EnumMultiset(Class<E> type) {
this.type = type;
Reported by PMD.
Line: 87
private transient E[] enumConstants;
private transient int[] counts;
private transient int distinctElements;
private transient long size;
/** Creates an empty {@code EnumMultiset}. */
private EnumMultiset(Class<E> type) {
this.type = type;
checkArgument(type.isEnum());
Reported by PMD.
Line: 100
private boolean isActuallyE(@CheckForNull Object o) {
if (o instanceof Enum) {
Enum<?> e = (Enum<?>) o;
int index = e.ordinal();
return index < enumConstants.length && enumConstants[index] == e;
}
return false;
}
Reported by PMD.
Line: 134
return 0;
}
Enum<?> e = (Enum<?>) element;
return counts[e.ordinal()];
}
// Modification Operations
@CanIgnoreReturnValue
@Override
Reported by PMD.
Line: 171
if (occurrences == 0) {
return count(element);
}
int index = e.ordinal();
int oldCount = counts[index];
if (oldCount == 0) {
return 0;
} else if (oldCount <= occurrences) {
counts[index] = 0;
Reported by PMD.
Line: 212
}
abstract class Itr<T> implements Iterator<T> {
int index = 0;
int toRemove = -1;
abstract T output(int index);
@Override
Reported by PMD.
Line: 212
}
abstract class Itr<T> implements Iterator<T> {
int index = 0;
int toRemove = -1;
abstract T output(int index);
@Override
Reported by PMD.
Line: 213
abstract class Itr<T> implements Iterator<T> {
int index = 0;
int toRemove = -1;
abstract T output(int index);
@Override
public boolean hasNext() {
Reported by PMD.
android/guava/src/com/google/common/collect/RegularImmutableSet.java
11 issues
Line: 39
// The first `size` elements are non-null.
@VisibleForTesting final transient @Nullable Object[] elements;
private final transient int hashCode;
// the same values as `elements` in hashed positions (plus nulls)
@VisibleForTesting final transient @Nullable Object[] table;
// 'and' with an int to get a valid table index.
private final transient int mask;
private final transient int size;
Reported by PMD.
Line: 44
@VisibleForTesting final transient @Nullable Object[] table;
// 'and' with an int to get a valid table index.
private final transient int mask;
private final transient int size;
RegularImmutableSet(
@Nullable Object[] elements, int hashCode, @Nullable Object[] table, int mask, int size) {
this.elements = elements;
this.hashCode = hashCode;
Reported by PMD.
Line: 47
private final transient int size;
RegularImmutableSet(
@Nullable Object[] elements, int hashCode, @Nullable Object[] table, int mask, int size) {
this.elements = elements;
this.hashCode = hashCode;
this.table = table;
this.mask = mask;
this.size = size;
Reported by PMD.
Line: 47
private final transient int size;
RegularImmutableSet(
@Nullable Object[] elements, int hashCode, @Nullable Object[] table, int mask, int size) {
this.elements = elements;
this.hashCode = hashCode;
this.table = table;
this.mask = mask;
this.size = size;
Reported by PMD.
Line: 62
return false;
}
for (int i = Hashing.smearedHash(target); ; i++) {
i &= mask;
Object candidate = table[i];
if (candidate == null) {
return false;
} else if (candidate.equals(target)) {
return true;
Reported by PMD.
Line: 66
Object candidate = table[i];
if (candidate == null) {
return false;
} else if (candidate.equals(target)) {
return true;
}
}
}
Reported by PMD.
Line: 79
@Override
public UnmodifiableIterator<E> iterator() {
return asList().iterator();
}
@Override
@Nullable
Object[] internalArray() {
Reported by PMD.
Line: 85
@Override
@Nullable
Object[] internalArray() {
return elements;
}
@Override
int internalArrayStart() {
return 0;
Reported by PMD.
Line: 115
}
@Override
public int hashCode() {
return hashCode;
}
@Override
boolean isHashCodeFast() {
Reported by PMD.
Line: 61
if (target == null || table.length == 0) {
return false;
}
for (int i = Hashing.smearedHash(target); ; i++) {
i &= mask;
Object candidate = table[i];
if (candidate == null) {
return false;
} else if (candidate.equals(target)) {
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/InterruptionUtil.java
11 issues
Line: 35
* @author Kevin Bourrillion
* @author Chris Povirk
*/
final class InterruptionUtil {
private static final Logger logger = Logger.getLogger(InterruptionUtil.class.getName());
/** Runnable which will interrupt the target thread repeatedly when run. */
private static final class Interruptenator implements Runnable {
private final long everyMillis;
Reported by PMD.
Line: 40
/** Runnable which will interrupt the target thread repeatedly when run. */
private static final class Interruptenator implements Runnable {
private final long everyMillis;
private final Thread interruptee;
private volatile boolean shouldStop = false;
Interruptenator(Thread interruptee, long everyMillis) {
this.everyMillis = everyMillis;
Reported by PMD.
Line: 41
/** Runnable which will interrupt the target thread repeatedly when run. */
private static final class Interruptenator implements Runnable {
private final long everyMillis;
private final Thread interruptee;
private volatile boolean shouldStop = false;
Interruptenator(Thread interruptee, long everyMillis) {
this.everyMillis = everyMillis;
this.interruptee = interruptee;
Reported by PMD.
Line: 42
private static final class Interruptenator implements Runnable {
private final long everyMillis;
private final Thread interruptee;
private volatile boolean shouldStop = false;
Interruptenator(Thread interruptee, long everyMillis) {
this.everyMillis = everyMillis;
this.interruptee = interruptee;
}
Reported by PMD.
Line: 42
private static final class Interruptenator implements Runnable {
private final long everyMillis;
private final Thread interruptee;
private volatile boolean shouldStop = false;
Interruptenator(Thread interruptee, long everyMillis) {
this.everyMillis = everyMillis;
this.interruptee = interruptee;
}
Reported by PMD.
Line: 96
interruptingThread.start();
tearDownAccepter.addTearDown(
new TearDown() {
@Override
public void tearDown() throws Exception {
interruptingTask.stopInterrupting();
interruptingThread.interrupt();
joinUninterruptibly(interruptingThread, 2500, MILLISECONDS);
Thread.interrupted();
Reported by PMD.
Line: 134
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
}
}
Reported by PMD.
Line: 72
/** Interrupts the current thread after sleeping for the specified delay. */
static void requestInterruptIn(final long time, final TimeUnit unit) {
checkNotNull(unit);
final Thread interruptee = Thread.currentThread();
new Thread(
new Runnable() {
@Override
public void run() {
try {
Reported by PMD.
Line: 72
/** Interrupts the current thread after sleeping for the specified delay. */
static void requestInterruptIn(final long time, final TimeUnit unit) {
checkNotNull(unit);
final Thread interruptee = Thread.currentThread();
new Thread(
new Runnable() {
@Override
public void run() {
try {
Reported by PMD.
Line: 117
// TODO(cpovirk): promote to Uninterruptibles, and add untimed version
private static void joinUninterruptibly(Thread thread, long timeout, TimeUnit unit) {
boolean interrupted = false;
try {
long remainingNanos = unit.toNanos(timeout);
long end = System.nanoTime() + remainingNanos;
while (true) {
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/testers/MapToStringTester.java
11 issues
Line: 44
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapToStringTester<K, V> extends AbstractMapTester<K, V> {
public void testToString_minimal() {
assertNotNull("toString() should not return null", getMap().toString());
}
@CollectionSize.Require(ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
Reported by PMD.
Line: 45
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public class MapToStringTester<K, V> extends AbstractMapTester<K, V> {
public void testToString_minimal() {
assertNotNull("toString() should not return null", getMap().toString());
}
@CollectionSize.Require(ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToString_size0() {
Reported by PMD.
Line: 48
assertNotNull("toString() should not return null", getMap().toString());
}
@CollectionSize.Require(ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToString_size0() {
assertEquals("emptyMap.toString should return {}", "{}", getMap().toString());
}
Reported by PMD.
Line: 51
@CollectionSize.Require(ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToString_size0() {
assertEquals("emptyMap.toString should return {}", "{}", getMap().toString());
}
@CollectionSize.Require(ONE)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToString_size1() {
Reported by PMD.
Line: 54
assertEquals("emptyMap.toString should return {}", "{}", getMap().toString());
}
@CollectionSize.Require(ONE)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToString_size1() {
assertEquals("size1Map.toString should return {entry}", "{" + e0() + "}", getMap().toString());
}
Reported by PMD.
Line: 57
@CollectionSize.Require(ONE)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToString_size1() {
assertEquals("size1Map.toString should return {entry}", "{" + e0() + "}", getMap().toString());
}
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
@MapFeature.Require(ALLOWS_NULL_KEYS)
Reported by PMD.
Line: 60
assertEquals("size1Map.toString should return {entry}", "{" + e0() + "}", getMap().toString());
}
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
@MapFeature.Require(ALLOWS_NULL_KEYS)
public void testToStringWithNullKey() {
initMapWithNullKey();
testToString_formatting();
Reported by PMD.
Line: 68
testToString_formatting();
}
@CollectionSize.Require(absent = ZERO)
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
@MapFeature.Require(ALLOWS_NULL_VALUES)
public void testToStringWithNullValue() {
initMapWithNullValue();
testToString_formatting();
Reported by PMD.
Line: 76
testToString_formatting();
}
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToString_formatting() {
assertEquals(
"map.toString() incorrect", expectedToString(getMap().entrySet()), getMap().toString());
}
Reported by PMD.
Line: 79
@CollectionFeature.Require(absent = NON_STANDARD_TOSTRING)
public void testToString_formatting() {
assertEquals(
"map.toString() incorrect", expectedToString(getMap().entrySet()), getMap().toString());
}
private String expectedToString(Set<Entry<K, V>> entries) {
Map<K, V> reference = new LinkedHashMap<>();
for (Entry<K, V> entry : entries) {
Reported by PMD.