The following issues were found
guava-testlib/src/com/google/common/collect/testing/google/DerivedGoogleCollectionGenerators.java
17 issues
Line: 42
* @author Louis Wasserman
*/
@GwtCompatible
public final class DerivedGoogleCollectionGenerators {
public static class MapGenerator<K, V> implements TestMapGenerator<K, V>, DerivedGenerator {
private final OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>> generator;
public MapGenerator(
Reported by PMD.
Line: 45
public final class DerivedGoogleCollectionGenerators {
public static class MapGenerator<K, V> implements TestMapGenerator<K, V>, DerivedGenerator {
private final OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>> generator;
public MapGenerator(
OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>> oneSizeTestContainerGenerator) {
this.generator = oneSizeTestContainerGenerator;
}
Reported by PMD.
Line: 72
return generator.order(insertionOrder);
}
@SuppressWarnings("unchecked")
@Override
public K[] createKeyArray(int length) {
return (K[]) new Object[length];
}
Reported by PMD.
Line: 93
public static class InverseBiMapGenerator<K, V>
implements TestBiMapGenerator<V, K>, DerivedGenerator {
private final OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>> generator;
public InverseBiMapGenerator(
OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>> oneSizeTestContainerGenerator) {
this.generator = oneSizeTestContainerGenerator;
}
Reported by PMD.
Line: 104
public SampleElements<Entry<V, K>> samples() {
SampleElements<Entry<K, V>> samples = generator.samples();
return new SampleElements<>(
reverse(samples.e0()),
reverse(samples.e1()),
reverse(samples.e2()),
reverse(samples.e3()),
reverse(samples.e4()));
}
Reported by PMD.
Line: 105
SampleElements<Entry<K, V>> samples = generator.samples();
return new SampleElements<>(
reverse(samples.e0()),
reverse(samples.e1()),
reverse(samples.e2()),
reverse(samples.e3()),
reverse(samples.e4()));
}
Reported by PMD.
Line: 106
return new SampleElements<>(
reverse(samples.e0()),
reverse(samples.e1()),
reverse(samples.e2()),
reverse(samples.e3()),
reverse(samples.e4()));
}
private Entry<V, K> reverse(Entry<K, V> entry) {
Reported by PMD.
Line: 107
reverse(samples.e0()),
reverse(samples.e1()),
reverse(samples.e2()),
reverse(samples.e3()),
reverse(samples.e4()));
}
private Entry<V, K> reverse(Entry<K, V> entry) {
return Helpers.mapEntry(entry.getValue(), entry.getKey());
Reported by PMD.
Line: 108
reverse(samples.e1()),
reverse(samples.e2()),
reverse(samples.e3()),
reverse(samples.e4()));
}
private Entry<V, K> reverse(Entry<K, V> entry) {
return Helpers.mapEntry(entry.getValue(), entry.getKey());
}
Reported by PMD.
Line: 156
public static class BiMapValueSetGenerator<K, V>
implements TestSetGenerator<V>, DerivedGenerator {
private final OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>> mapGenerator;
private final SampleElements<V> samples;
public BiMapValueSetGenerator(
OneSizeTestContainerGenerator<BiMap<K, V>, Entry<K, V>> mapGenerator) {
this.mapGenerator = mapGenerator;
Reported by PMD.
android/guava/src/com/google/common/collect/ObjectArrays.java
17 issues
Line: 231
@CanIgnoreReturnValue
static Object checkElementNotNull(@CheckForNull Object element, int index) {
if (element == null) {
throw new NullPointerException("at index " + index);
}
return element;
}
}
Reported by PMD.
Line: 129
* @throws ArrayStoreException if the runtime type of the specified array is not a supertype of
* the runtime type of every element in the specified collection
*/
static <T extends @Nullable Object> T[] toArrayImpl(Collection<?> c, T[] array) {
int size = c.size();
if (array.length < size) {
array = newArray(array, size);
}
fillArray(c, array);
Reported by PMD.
Line: 154
* <i>only</i> if the caller knows that the collection does not contain any null elements.
*/
static <T extends @Nullable Object> T[] toArrayImpl(
@Nullable Object[] src, int offset, int len, T[] dst) {
checkPositionIndexes(offset, offset + len, src.length);
if (dst.length < len) {
dst = newArray(dst, len);
} else if (dst.length > len) {
@Nullable Object[] unsoundlyCovariantArray = dst;
Reported by PMD.
Line: 38
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class ObjectArrays {
private ObjectArrays() {}
/**
* Returns a new array of the given length with the specified component type.
Reported by PMD.
Line: 137
fillArray(c, array);
if (array.length > size) {
@Nullable Object[] unsoundlyCovariantArray = array;
unsoundlyCovariantArray[size] = null;
}
return array;
}
/**
Reported by PMD.
Line: 160
dst = newArray(dst, len);
} else if (dst.length > len) {
@Nullable Object[] unsoundlyCovariantArray = dst;
unsoundlyCovariantArray[len] = null;
}
System.arraycopy(src, offset, dst, 0, len);
return dst;
}
Reported by PMD.
Line: 87
* @return an array whose size is one larger than {@code array}, with {@code element} occupying
* the first position, and the elements of {@code array} occupying the remaining elements.
*/
public static <T extends @Nullable Object> T[] concat(@ParametricNullness T element, T[] array) {
T[] result = newArray(array, array.length + 1);
result[0] = element;
System.arraycopy(array, 0, result, 1, array.length);
return result;
}
Reported by PMD.
Line: 129
* @throws ArrayStoreException if the runtime type of the specified array is not a supertype of
* the runtime type of every element in the specified collection
*/
static <T extends @Nullable Object> T[] toArrayImpl(Collection<?> c, T[] array) {
int size = c.size();
if (array.length < size) {
array = newArray(array, size);
}
fillArray(c, array);
Reported by PMD.
Line: 154
* <i>only</i> if the caller knows that the collection does not contain any null elements.
*/
static <T extends @Nullable Object> T[] toArrayImpl(
@Nullable Object[] src, int offset, int len, T[] dst) {
checkPositionIndexes(offset, offset + len, src.length);
if (dst.length < len) {
dst = newArray(dst, len);
} else if (dst.length > len) {
@Nullable Object[] unsoundlyCovariantArray = dst;
Reported by PMD.
Line: 197
}
@CanIgnoreReturnValue
private static @Nullable Object[] fillArray(Iterable<?> elements, @Nullable Object[] array) {
int i = 0;
for (Object element : elements) {
array[i++] = element;
}
return array;
Reported by PMD.
android/guava/src/com/google/common/net/HostAndPort.java
17 issues
Line: 78
private final int port;
/** True if the parsed host has colons, but no surrounding brackets. */
private final boolean hasBracketlessColons;
private HostAndPort(String host, int port, boolean hasBracketlessColons) {
this.host = host;
this.port = port;
this.hasBracketlessColons = hasBracketlessColons;
Reported by PMD.
Line: 136
public static HostAndPort fromParts(String host, int port) {
checkArgument(isValidPort(port), "Port out of range: %s", port);
HostAndPort parsedHost = fromString(host);
checkArgument(!parsedHost.hasPort(), "Host has a port: %s", host);
return new HostAndPort(parsedHost.host, port, parsedHost.hasBracketlessColons);
}
/**
* Build a HostAndPort instance from a host only.
Reported by PMD.
Line: 153
*/
public static HostAndPort fromHost(String host) {
HostAndPort parsedHost = fromString(host);
checkArgument(!parsedHost.hasPort(), "Host has a port: %s", host);
return parsedHost;
}
/**
* Split a freeform string into a host and port, without strict validation.
Reported by PMD.
Line: 173
String portString = null;
boolean hasBracketlessColons = false;
if (hostPortString.startsWith("[")) {
String[] hostAndPort = getHostAndPortFromBracketedHost(hostPortString);
host = hostAndPort[0];
portString = hostAndPort[1];
} else {
int colonPos = hostPortString.indexOf(':');
Reported by PMD.
Line: 195
// Try to parse the whole port string as a number.
// JDK7 accepts leading plus signs. We don't want to.
checkArgument(
!portString.startsWith("+") && CharMatcher.ascii().matchesAllOf(portString),
"Unparseable port number: %s",
hostPortString);
try {
port = Integer.parseInt(portString);
} catch (NumberFormatException e) {
Reported by PMD.
Line: 195
// Try to parse the whole port string as a number.
// JDK7 accepts leading plus signs. We don't want to.
checkArgument(
!portString.startsWith("+") && CharMatcher.ascii().matchesAllOf(portString),
"Unparseable port number: %s",
hostPortString);
try {
port = Integer.parseInt(portString);
} catch (NumberFormatException e) {
Reported by PMD.
Line: 201
try {
port = Integer.parseInt(portString);
} catch (NumberFormatException e) {
throw new IllegalArgumentException("Unparseable port number: " + hostPortString);
}
checkArgument(isValidPort(port), "Port number out of range: %s", hostPortString);
}
return new HostAndPort(host, port, hasBracketlessColons);
Reported by PMD.
Line: 170
public static HostAndPort fromString(String hostPortString) {
checkNotNull(hostPortString);
String host;
String portString = null;
boolean hasBracketlessColons = false;
if (hostPortString.startsWith("[")) {
String[] hostAndPort = getHostAndPortFromBracketedHost(hostPortString);
host = hostAndPort[0];
Reported by PMD.
Line: 170
public static HostAndPort fromString(String hostPortString) {
checkNotNull(hostPortString);
String host;
String portString = null;
boolean hasBracketlessColons = false;
if (hostPortString.startsWith("[")) {
String[] hostAndPort = getHostAndPortFromBracketedHost(hostPortString);
host = hostAndPort[0];
Reported by PMD.
Line: 171
checkNotNull(hostPortString);
String host;
String portString = null;
boolean hasBracketlessColons = false;
if (hostPortString.startsWith("[")) {
String[] hostAndPort = getHostAndPortFromBracketedHost(hostPortString);
host = hostAndPort[0];
portString = hostAndPort[1];
Reported by PMD.
android/guava/src/com/google/common/base/internal/Finalizer.java
17 issues
Line: 46
* collected, and this class can detect when the main class loader has been garbage collected and
* stop itself.
*/
public class Finalizer implements Runnable {
private static final Logger logger = Logger.getLogger(Finalizer.class.getName());
/** Name of FinalizableReference.class. */
private static final String FINALIZABLE_REFERENCE = "com.google.common.base.FinalizableReference";
Reported by PMD.
Line: 161
* @return true if the caller should continue, false if the associated FinalizableReferenceQueue
* is no longer referenced.
*/
private boolean cleanUp(Reference<?> reference) {
Method finalizeReferentMethod = getFinalizeReferentMethod();
if (finalizeReferentMethod == null) {
return false;
}
do {
Reported by PMD.
Line: 221
inheritableThreadLocals.setAccessible(true);
return inheritableThreadLocals;
} catch (Throwable t) {
logger.log(
Level.INFO,
"Couldn't access Thread.inheritableThreadLocals. Reference finalizer threads will "
+ "inherit thread local values.");
return null;
}
Reported by PMD.
Line: 74
* 2) To detect when FinalizableReference's class loader has to be garbage collected, at which
* point, Finalizer can stop running
*/
if (!finalizableReferenceClass.getName().equals(FINALIZABLE_REFERENCE)) {
throw new IllegalArgumentException("Expected " + FINALIZABLE_REFERENCE + ".");
}
Finalizer finalizer = new Finalizer(finalizableReferenceClass, queue, frqReference);
String threadName = Finalizer.class.getName();
Reported by PMD.
Line: 88
thread =
bigThreadConstructor.newInstance(
(ThreadGroup) null, finalizer, threadName, defaultStackSize, inheritThreadLocals);
} catch (Throwable t) {
logger.log(
Level.INFO, "Failed to create a thread without inherited thread-local values", t);
}
}
if (thread == null) {
Reported by PMD.
Line: 102
if (inheritableThreadLocals != null) {
inheritableThreadLocals.set(thread, null);
}
} catch (Throwable t) {
logger.log(
Level.INFO,
"Failed to clear thread local values inherited by reference finalizer thread.",
t);
}
Reported by PMD.
Line: 112
thread.start();
}
private final WeakReference<Class<?>> finalizableReferenceClassReference;
private final PhantomReference<Object> frqReference;
private final ReferenceQueue<Object> queue;
// By preference, we will use the Thread constructor that has an `inheritThreadLocals` parameter.
// But before Java 9, our only way not to inherit ThreadLocals is to zap them after the thread
Reported by PMD.
Line: 113
}
private final WeakReference<Class<?>> finalizableReferenceClassReference;
private final PhantomReference<Object> frqReference;
private final ReferenceQueue<Object> queue;
// By preference, we will use the Thread constructor that has an `inheritThreadLocals` parameter.
// But before Java 9, our only way not to inherit ThreadLocals is to zap them after the thread
// is created, by accessing a private field.
Reported by PMD.
Line: 114
private final WeakReference<Class<?>> finalizableReferenceClassReference;
private final PhantomReference<Object> frqReference;
private final ReferenceQueue<Object> queue;
// By preference, we will use the Thread constructor that has an `inheritThreadLocals` parameter.
// But before Java 9, our only way not to inherit ThreadLocals is to zap them after the thread
// is created, by accessing a private field.
@NullableDecl
Reported by PMD.
Line: 173
*/
reference.clear();
if (reference == frqReference) {
/*
* The client no longer has a reference to the FinalizableReferenceQueue. We can stop.
*/
return false;
}
Reported by PMD.
android/guava/src/com/google/common/graph/Traverser.java
17 issues
Line: 69
+ " GraphBuilder)")
@ElementTypesAreNonnullByDefault
public abstract class Traverser<N> {
private final SuccessorsFunction<N> successorFunction;
private Traverser(SuccessorsFunction<N> successorFunction) {
this.successorFunction = checkNotNull(successorFunction);
}
Reported by PMD.
Line: 246
return new Iterable<N>() {
@Override
public Iterator<N> iterator() {
return newTraversal().breadthFirst(validated.iterator());
}
};
}
/**
Reported by PMD.
Line: 301
return new Iterable<N>() {
@Override
public Iterator<N> iterator() {
return newTraversal().preOrder(validated.iterator());
}
};
}
/**
Reported by PMD.
Line: 356
return new Iterable<N>() {
@Override
public Iterator<N> iterator() {
return newTraversal().postOrder(validated.iterator());
}
};
}
abstract Traversal<N> newTraversal();
Reported by PMD.
Line: 378
* non-empty iterator to find first unvisited node.
*/
private abstract static class Traversal<N> {
final SuccessorsFunction<N> successorFunction;
Traversal(SuccessorsFunction<N> successorFunction) {
this.successorFunction = successorFunction;
}
Reported by PMD.
Line: 451
do {
N next = visitNext(horizon);
if (next != null) {
Iterator<? extends N> successors = successorFunction.successors(next).iterator();
if (successors.hasNext()) {
// BFS: horizon.addLast(successors)
// Pre-order: horizon.addFirst(successors)
order.insertInto(horizon, successors);
}
Reported by PMD.
Line: 474
@CheckForNull
protected N computeNext() {
for (N next = visitNext(horizon); next != null; next = visitNext(horizon)) {
Iterator<? extends N> successors = successorFunction.successors(next).iterator();
if (!successors.hasNext()) {
return next;
}
horizon.addFirst(successors);
ancestorStack.push(next);
Reported by PMD.
Line: 242
* @since 24.1
*/
public final Iterable<N> breadthFirst(Iterable<? extends N> startNodes) {
final ImmutableSet<N> validated = validate(startNodes);
return new Iterable<N>() {
@Override
public Iterator<N> iterator() {
return newTraversal().breadthFirst(validated.iterator());
}
Reported by PMD.
Line: 242
* @since 24.1
*/
public final Iterable<N> breadthFirst(Iterable<? extends N> startNodes) {
final ImmutableSet<N> validated = validate(startNodes);
return new Iterable<N>() {
@Override
public Iterator<N> iterator() {
return newTraversal().breadthFirst(validated.iterator());
}
Reported by PMD.
Line: 297
* @since 24.1
*/
public final Iterable<N> depthFirstPreOrder(Iterable<? extends N> startNodes) {
final ImmutableSet<N> validated = validate(startNodes);
return new Iterable<N>() {
@Override
public Iterator<N> iterator() {
return newTraversal().preOrder(validated.iterator());
}
Reported by PMD.
guava-gwt/src-super/com/google/common/util/concurrent/super/com/google/common/util/concurrent/AbstractFuture.java
17 issues
Line: 375
try {
executor.execute(command);
} catch (RuntimeException e) {
log.log(
Level.SEVERE,
"RuntimeException while executing runnable " + command + " with executor " + executor,
e);
}
}
Reported by PMD.
Line: 41
/** Emulation for AbstractFuture in GWT. */
@SuppressWarnings("nullness") // TODO(b/147136275): Remove once our checker understands & and |.
public abstract class AbstractFuture<V> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
/**
* Tag interface marking trusted subclasses. This enables some optimizations. The implementation
* of this interface must also be an AbstractFuture and must not override or expose for overriding
* any of the public methods of ListenableFuture.
Reported by PMD.
Line: 85
private static final Logger log = Logger.getLogger(AbstractFuture.class.getName());
private State state;
private V value;
private Future<? extends V> delegate;
private Throwable throwable;
private boolean mayInterruptIfRunning;
private List<Listener> listeners;
Reported by PMD.
Line: 86
private static final Logger log = Logger.getLogger(AbstractFuture.class.getName());
private State state;
private V value;
private Future<? extends V> delegate;
private Throwable throwable;
private boolean mayInterruptIfRunning;
private List<Listener> listeners;
Reported by PMD.
Line: 87
private State state;
private V value;
private Future<? extends V> delegate;
private Throwable throwable;
private boolean mayInterruptIfRunning;
private List<Listener> listeners;
protected AbstractFuture() {
Reported by PMD.
Line: 88
private State state;
private V value;
private Future<? extends V> delegate;
private Throwable throwable;
private boolean mayInterruptIfRunning;
private List<Listener> listeners;
protected AbstractFuture() {
state = State.PENDING;
Reported by PMD.
Line: 89
private V value;
private Future<? extends V> delegate;
private Throwable throwable;
private boolean mayInterruptIfRunning;
private List<Listener> listeners;
protected AbstractFuture() {
state = State.PENDING;
listeners = new ArrayList<Listener>();
Reported by PMD.
Line: 90
private Future<? extends V> delegate;
private Throwable throwable;
private boolean mayInterruptIfRunning;
private List<Listener> listeners;
protected AbstractFuture() {
state = State.PENDING;
listeners = new ArrayList<Listener>();
}
Reported by PMD.
Line: 216
for (Listener listener : listeners) {
listener.execute();
}
listeners = null;
}
protected void afterDone() {}
@Override
Reported by PMD.
Line: 251
String pendingDescription;
try {
pendingDescription = pendingToString();
} catch (RuntimeException e) {
// Don't call getMessage or toString() on the exception, in case the exception thrown by the
// subclass is implemented with bugs similar to the subclass.
pendingDescription = "Exception thrown from implementation: " + e.getClass();
}
// The future may complete during or before the call to getPendingToString, so we use null
Reported by PMD.
android/guava/src/com/google/common/hash/Hashing.java
17 issues
Line: 47
*/
@Beta
@ElementTypesAreNonnullByDefault
public final class Hashing {
/**
* Returns a general-purpose, <b>temporary-use</b>, non-cryptographic hash function. The algorithm
* the returned function implements is unspecified and subject to change without notice.
*
* <p><b>Warning:</b> a new random seed for these functions is chosen each time the {@code
Reported by PMD.
Line: 68
public static HashFunction goodFastHash(int minimumBits) {
int bits = checkPositiveAndMakeMultipleOf32(minimumBits);
if (bits == 32) {
return Murmur3_32HashFunction.GOOD_FAST_HASH_32;
}
if (bits <= 128) {
return Murmur3_128HashFunction.GOOD_FAST_HASH_128;
}
Reported by PMD.
Line: 71
if (bits == 32) {
return Murmur3_32HashFunction.GOOD_FAST_HASH_32;
}
if (bits <= 128) {
return Murmur3_128HashFunction.GOOD_FAST_HASH_128;
}
// Otherwise, join together some 128-bit murmur3s
int hashFunctionsNeeded = (bits + 127) / 128;
Reported by PMD.
Line: 519
public static HashCode combineOrdered(Iterable<HashCode> hashCodes) {
Iterator<HashCode> iterator = hashCodes.iterator();
checkArgument(iterator.hasNext(), "Must be at least 1 hash code to combine.");
int bits = iterator.next().bits();
byte[] resultBytes = new byte[bits / 8];
for (HashCode hashCode : hashCodes) {
byte[] nextBytes = hashCode.asBytes();
checkArgument(
nextBytes.length == resultBytes.length, "All hashcodes must have the same bit length.");
Reported by PMD.
Line: 544
public static HashCode combineUnordered(Iterable<HashCode> hashCodes) {
Iterator<HashCode> iterator = hashCodes.iterator();
checkArgument(iterator.hasNext(), "Must be at least 1 hash code to combine.");
byte[] resultBytes = new byte[iterator.next().bits() / 8];
for (HashCode hashCode : hashCodes) {
byte[] nextBytes = hashCode.asBytes();
checkArgument(
nextBytes.length == resultBytes.length, "All hashcodes must have the same bit length.");
for (int i = 0; i < nextBytes.length; i++) {
Reported by PMD.
Line: 599
for (HashFunction hashFunction : hashFunctions) {
list.add(hashFunction);
}
checkArgument(list.size() > 0, "number of hash functions (%s) must be > 0", list.size());
return new ConcatenatedHashFunction(list.toArray(new HashFunction[0]));
}
private static final class ConcatenatedHashFunction extends AbstractCompositeHashFunction {
Reported by PMD.
Line: 622
int i = 0;
for (Hasher hasher : hashers) {
HashCode newHash = hasher.hash();
i += newHash.writeBytesTo(bytes, i, newHash.bits() / 8);
}
return HashCode.fromBytesNoCopy(bytes);
}
@Override
Reported by PMD.
Line: 622
int i = 0;
for (Hasher hasher : hashers) {
HashCode newHash = hasher.hash();
i += newHash.writeBytesTo(bytes, i, newHash.bits() / 8);
}
return HashCode.fromBytesNoCopy(bytes);
}
@Override
Reported by PMD.
Line: 656
* http://en.wikipedia.org/wiki/Linear_congruential_generator
*/
private static final class LinearCongruentialGenerator {
private long state;
public LinearCongruentialGenerator(long seed) {
this.state = seed;
}
Reported by PMD.
Line: 77
// Otherwise, join together some 128-bit murmur3s
int hashFunctionsNeeded = (bits + 127) / 128;
HashFunction[] hashFunctions = new HashFunction[hashFunctionsNeeded];
hashFunctions[0] = Murmur3_128HashFunction.GOOD_FAST_HASH_128;
int seed = GOOD_FAST_HASH_SEED;
for (int i = 1; i < hashFunctionsNeeded; i++) {
seed += 1500450271; // a prime; shouldn't matter
hashFunctions[i] = murmur3_128(seed);
Reported by PMD.
guava-testlib/src/com/google/common/collect/testing/AbstractContainerTester.java
17 issues
Line: 39
@GwtCompatible
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public abstract class AbstractContainerTester<C, E>
extends AbstractTester<OneSizeTestContainerGenerator<C, E>> {
protected SampleElements<E> samples;
protected C container;
@Override
@OverridingMethodsMustInvokeSuper
Reported by PMD.
Line: 40
@Ignore // Affects only Android test runner, which respects JUnit 4 annotations on JUnit 3 tests.
public abstract class AbstractContainerTester<C, E>
extends AbstractTester<OneSizeTestContainerGenerator<C, E>> {
protected SampleElements<E> samples;
protected C container;
@Override
@OverridingMethodsMustInvokeSuper
public void setUp() throws Exception {
Reported by PMD.
Line: 41
public abstract class AbstractContainerTester<C, E>
extends AbstractTester<OneSizeTestContainerGenerator<C, E>> {
protected SampleElements<E> samples;
protected C container;
@Override
@OverridingMethodsMustInvokeSuper
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 43
protected SampleElements<E> samples;
protected C container;
@Override
@OverridingMethodsMustInvokeSuper
public void setUp() throws Exception {
super.setUp();
samples = this.getSubjectGenerator().samples();
resetContainer();
Reported by PMD.
Line: 65
* @return the new container instance.
*/
protected C resetContainer() {
return resetContainer(getSubjectGenerator().createTestSubject());
}
/**
* Replaces the existing container under test with a new container. This is useful when a single
* test method needs to create multiple containers while retaining the ability to use {@link
Reported by PMD.
Line: 136
*/
protected final void expectAdded(E... elements) {
List<E> expected = Helpers.copyToList(getSampleElements());
expected.addAll(Arrays.asList(elements));
expectContents(expected);
}
protected final void expectAdded(int index, E... elements) {
expectAdded(index, Arrays.asList(elements));
Reported by PMD.
Line: 146
protected final void expectAdded(int index, Collection<E> elements) {
List<E> expected = Helpers.copyToList(getSampleElements());
expected.addAll(index, elements);
expectContents(expected);
}
/*
* TODO: if we're testing a list, we could check indexOf(). (Doing it in
Reported by PMD.
Line: 158
*/
protected void expectMissing(E... elements) {
for (E element : elements) {
assertFalse("Should not contain " + element, actualContents().contains(element));
}
}
protected E[] createSamplesArray() {
E[] array = getSubjectGenerator().createArray(getNumElements());
Reported by PMD.
Line: 163
}
protected E[] createSamplesArray() {
E[] array = getSubjectGenerator().createArray(getNumElements());
getSampleElements().toArray(array);
return array;
}
protected E[] createOrderedArray() {
Reported by PMD.
Line: 164
protected E[] createSamplesArray() {
E[] array = getSubjectGenerator().createArray(getNumElements());
getSampleElements().toArray(array);
return array;
}
protected E[] createOrderedArray() {
E[] array = getSubjectGenerator().createArray(getNumElements());
Reported by PMD.
android/guava/src/com/google/common/hash/SipHashFunction.java
17 issues
Line: 43
new SipHashFunction(2, 4, 0x0706050403020100L, 0x0f0e0d0c0b0a0908L);
// The number of compression rounds.
private final int c;
// The number of finalization rounds.
private final int d;
// Two 64-bit keys (represent a single 128-bit key).
private final long k0;
private final long k1;
Reported by PMD.
Line: 45
// The number of compression rounds.
private final int c;
// The number of finalization rounds.
private final int d;
// Two 64-bit keys (represent a single 128-bit key).
private final long k0;
private final long k1;
/**
Reported by PMD.
Line: 47
// The number of finalization rounds.
private final int d;
// Two 64-bit keys (represent a single 128-bit key).
private final long k0;
private final long k1;
/**
* @param c the number of compression rounds (must be positive)
* @param d the number of finalization rounds (must be positive)
Reported by PMD.
Line: 48
private final int d;
// Two 64-bit keys (represent a single 128-bit key).
private final long k0;
private final long k1;
/**
* @param c the number of compression rounds (must be positive)
* @param d the number of finalization rounds (must be positive)
* @param k0 the first half of the key
Reported by PMD.
Line: 81
@Override
public String toString() {
return "Hashing.sipHash" + c + "" + d + "(" + k0 + ", " + k1 + ")";
}
@Override
public boolean equals(@CheckForNull Object object) {
if (object instanceof SipHashFunction) {
Reported by PMD.
Line: 95
@Override
public int hashCode() {
return (int) (getClass().hashCode() ^ c ^ d ^ k0 ^ k1);
}
private static final class SipHasher extends AbstractStreamingHasher {
private static final int CHUNK_SIZE = 8;
Reported by PMD.
Line: 102
private static final int CHUNK_SIZE = 8;
// The number of compression rounds.
private final int c;
// The number of finalization rounds.
private final int d;
// Four 64-bit words of internal state.
// The initial state corresponds to the ASCII string "somepseudorandomlygeneratedbytes",
Reported by PMD.
Line: 104
// The number of compression rounds.
private final int c;
// The number of finalization rounds.
private final int d;
// Four 64-bit words of internal state.
// The initial state corresponds to the ASCII string "somepseudorandomlygeneratedbytes",
// big-endian encoded. There is nothing special about this value; the only requirement
// was some asymmetry so that the initial v0 and v1 differ from v2 and v3.
Reported by PMD.
Line: 110
// The initial state corresponds to the ASCII string "somepseudorandomlygeneratedbytes",
// big-endian encoded. There is nothing special about this value; the only requirement
// was some asymmetry so that the initial v0 and v1 differ from v2 and v3.
private long v0 = 0x736f6d6570736575L;
private long v1 = 0x646f72616e646f6dL;
private long v2 = 0x6c7967656e657261L;
private long v3 = 0x7465646279746573L;
// The number of bytes in the input.
Reported by PMD.
Line: 111
// big-endian encoded. There is nothing special about this value; the only requirement
// was some asymmetry so that the initial v0 and v1 differ from v2 and v3.
private long v0 = 0x736f6d6570736575L;
private long v1 = 0x646f72616e646f6dL;
private long v2 = 0x6c7967656e657261L;
private long v3 = 0x7465646279746573L;
// The number of bytes in the input.
private long b = 0;
Reported by PMD.
guava-tests/test/com/google/common/net/HttpHeadersTest.java
17 issues
Line: 36
*/
public class HttpHeadersTest extends TestCase {
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases =
ImmutableBiMap.<String, String>builder()
.put("CDN_LOOP", "CDN-Loop")
.put("ETAG", "ETag")
Reported by PMD.
Line: 39
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases =
ImmutableBiMap.<String, String>builder()
.put("CDN_LOOP", "CDN-Loop")
.put("ETAG", "ETag")
.put("SOURCE_MAP", "SourceMap")
.put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
.put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")
Reported by PMD.
Line: 39
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases =
ImmutableBiMap.<String, String>builder()
.put("CDN_LOOP", "CDN-Loop")
.put("ETAG", "ETag")
.put("SOURCE_MAP", "SourceMap")
.put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
.put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")
Reported by PMD.
Line: 39
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases =
ImmutableBiMap.<String, String>builder()
.put("CDN_LOOP", "CDN-Loop")
.put("ETAG", "ETag")
.put("SOURCE_MAP", "SourceMap")
.put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
.put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")
Reported by PMD.
Line: 39
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases =
ImmutableBiMap.<String, String>builder()
.put("CDN_LOOP", "CDN-Loop")
.put("ETAG", "ETag")
.put("SOURCE_MAP", "SourceMap")
.put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
.put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")
Reported by PMD.
Line: 39
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases =
ImmutableBiMap.<String, String>builder()
.put("CDN_LOOP", "CDN-Loop")
.put("ETAG", "ETag")
.put("SOURCE_MAP", "SourceMap")
.put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
.put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")
Reported by PMD.
Line: 39
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases =
ImmutableBiMap.<String, String>builder()
.put("CDN_LOOP", "CDN-Loop")
.put("ETAG", "ETag")
.put("SOURCE_MAP", "SourceMap")
.put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
.put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")
Reported by PMD.
Line: 39
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases =
ImmutableBiMap.<String, String>builder()
.put("CDN_LOOP", "CDN-Loop")
.put("ETAG", "ETag")
.put("SOURCE_MAP", "SourceMap")
.put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
.put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")
Reported by PMD.
Line: 39
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases =
ImmutableBiMap.<String, String>builder()
.put("CDN_LOOP", "CDN-Loop")
.put("ETAG", "ETag")
.put("SOURCE_MAP", "SourceMap")
.put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
.put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")
Reported by PMD.
Line: 39
public void testConstantNameMatchesString() throws Exception {
// Special case some of the weird HTTP Header names...
ImmutableBiMap<String, String> specialCases =
ImmutableBiMap.<String, String>builder()
.put("CDN_LOOP", "CDN-Loop")
.put("ETAG", "ETag")
.put("SOURCE_MAP", "SourceMap")
.put("SEC_WEBSOCKET_ACCEPT", "Sec-WebSocket-Accept")
.put("SEC_WEBSOCKET_EXTENSIONS", "Sec-WebSocket-Extensions")
Reported by PMD.