The following issues were found
guava/src/com/google/common/collect/AbstractIterator.java
4 issues
Line: 68
@GwtCompatible
@ElementTypesAreNonnullByDefault
public abstract class AbstractIterator<T extends @Nullable Object> extends UnmodifiableIterator<T> {
private State state = State.NOT_READY;
/** Constructor for use by subclasses. */
protected AbstractIterator() {}
private enum State {
Reported by PMD.
Line: 87
FAILED,
}
@CheckForNull private T next;
/**
* Returns the next element. <b>Note:</b> the implementation must call {@link #endOfData()} when
* there are no elements left in the iteration. Failure to do so could result in an infinite loop.
*
Reported by PMD.
Line: 87
FAILED,
}
@CheckForNull private T next;
/**
* Returns the next element. <b>Note:</b> the implementation must call {@link #endOfData()} when
* there are no elements left in the iteration. Failure to do so could result in an infinite loop.
*
Reported by PMD.
Line: 164
state = State.NOT_READY;
// Safe because hasNext() ensures that tryToComputeNext() has put a T into `next`.
T result = uncheckedCastNullableTToT(next);
next = null;
return result;
}
/**
* Returns the next element in the iteration without advancing the iteration, according to the
Reported by PMD.
guava/src/com/google/common/util/concurrent/UncaughtExceptionHandlers.java
4 issues
Line: 74
} catch (Throwable errorInLogging) {
// If logging fails, e.g. due to missing memory, at least try to log the
// message and the cause for the failed logging.
System.err.println(e.getMessage());
System.err.println(errorInLogging.getMessage());
} finally {
runtime.exit(1);
}
}
Reported by PMD.
Line: 75
// If logging fails, e.g. due to missing memory, at least try to log the
// message and the cause for the failed logging.
System.err.println(e.getMessage());
System.err.println(errorInLogging.getMessage());
} finally {
runtime.exit(1);
}
}
}
Reported by PMD.
Line: 60
static final class Exiter implements UncaughtExceptionHandler {
private static final Logger logger = Logger.getLogger(Exiter.class.getName());
private final Runtime runtime;
Exiter(Runtime runtime) {
this.runtime = runtime;
}
Reported by PMD.
Line: 71
try {
logger.log(
SEVERE, String.format(Locale.ROOT, "Caught an exception in %s. Shutting down.", t), e);
} catch (Throwable errorInLogging) {
// If logging fails, e.g. due to missing memory, at least try to log the
// message and the cause for the failed logging.
System.err.println(e.getMessage());
System.err.println(errorInLogging.getMessage());
} finally {
Reported by PMD.
guava/src/com/google/common/graph/DirectedMultiNetworkConnections.java
4 issues
Line: 43
* @param <E> Edge parameter type
*/
@ElementTypesAreNonnullByDefault
final class DirectedMultiNetworkConnections<N, E> extends AbstractDirectedNetworkConnections<N, E> {
private DirectedMultiNetworkConnections(
Map<E, N> inEdges, Map<E, N> outEdges, int selfLoopCount) {
super(inEdges, outEdges, selfLoopCount);
}
Reported by PMD.
Line: 67
@Override
public Set<N> predecessors() {
return Collections.unmodifiableSet(predecessorsMultiset().elementSet());
}
private Multiset<N> predecessorsMultiset() {
Multiset<N> predecessors = getReference(predecessorsReference);
if (predecessors == null) {
Reported by PMD.
Line: 83
@Override
public Set<N> successors() {
return Collections.unmodifiableSet(successorsMultiset().elementSet());
}
private Multiset<N> successorsMultiset() {
Multiset<N> successors = getReference(successorsReference);
if (successors == null) {
Reported by PMD.
Line: 100
return new MultiEdgesConnecting<E>(outEdgeMap, node) {
@Override
public int size() {
return successorsMultiset().count(node);
}
};
}
@Override
Reported by PMD.
guava/src/com/google/common/collect/Queues.java
4 issues
Line: 46
*/
@GwtCompatible(emulated = true)
@ElementTypesAreNonnullByDefault
public final class Queues {
private Queues() {}
// ArrayBlockingQueue
/**
Reported by PMD.
Line: 406
}
} finally {
if (interrupted) {
Thread.currentThread().interrupt();
}
}
return added;
}
Reported by PMD.
Line: 312
* execute Queue#drainTo is not added *on top* of waiting for the timeout (which could make
* the timeout arbitrarily inaccurate, given a queue that is slow to drain).
*/
long deadline = System.nanoTime() + unit.toNanos(timeout);
int added = 0;
while (added < numElements) {
// we could rely solely on #poll, but #drainTo might be more efficient when there are multiple
// elements already available (e.g. LinkedBlockingQueue#drainTo locks only once)
added += q.drainTo(buffer, numElements - added);
Reported by PMD.
Line: 379
long timeout,
TimeUnit unit) {
Preconditions.checkNotNull(buffer);
long deadline = System.nanoTime() + unit.toNanos(timeout);
int added = 0;
boolean interrupted = false;
try {
while (added < numElements) {
// we could rely solely on #poll, but #drainTo might be more efficient when there are
Reported by PMD.
guava/src/com/google/common/collect/ImmutableSortedAsList.java
4 issues
Line: 45
@Override
public Comparator<? super E> comparator() {
return delegateCollection().comparator();
}
// Override indexOf() and lastIndexOf() to be O(log N) instead of O(N).
@GwtIncompatible // ImmutableSortedSet.indexOf
Reported by PMD.
Line: 54
// TODO(cpovirk): consider manual binary search under GWT to preserve O(log N) lookup
@Override
public int indexOf(@CheckForNull Object target) {
int index = delegateCollection().indexOf(target);
// TODO(kevinb): reconsider if it's really worth making feeble attempts at
// sanity for inconsistent comparators.
// The equals() check is needed when the comparator isn't compatible with
Reported by PMD.
Line: 61
// The equals() check is needed when the comparator isn't compatible with
// equals().
return (index >= 0 && get(index).equals(target)) ? index : -1;
}
@GwtIncompatible // ImmutableSortedSet.indexOf
@Override
public int lastIndexOf(@CheckForNull Object target) {
Reported by PMD.
Line: 93
return CollectSpliterators.indexed(
size(),
ImmutableList.SPLITERATOR_CHARACTERISTICS | Spliterator.SORTED | Spliterator.DISTINCT,
delegateList()::get,
comparator());
}
}
Reported by PMD.
guava/src/com/google/common/collect/ForwardingSetMultimap.java
4 issues
Line: 48
@Override
public Set<Entry<K, V>> entries() {
return delegate().entries();
}
@Override
public Set<V> get(@ParametricNullness K key) {
return delegate().get(key);
Reported by PMD.
Line: 53
@Override
public Set<V> get(@ParametricNullness K key) {
return delegate().get(key);
}
@CanIgnoreReturnValue
@Override
public Set<V> removeAll(@CheckForNull Object key) {
Reported by PMD.
Line: 59
@CanIgnoreReturnValue
@Override
public Set<V> removeAll(@CheckForNull Object key) {
return delegate().removeAll(key);
}
@CanIgnoreReturnValue
@Override
public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
Reported by PMD.
Line: 65
@CanIgnoreReturnValue
@Override
public Set<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
return delegate().replaceValues(key, values);
}
}
Reported by PMD.
guava/src/com/google/common/collect/ForwardingSortedSetMultimap.java
4 issues
Line: 51
@Override
public SortedSet<V> get(@ParametricNullness K key) {
return delegate().get(key);
}
@Override
public SortedSet<V> removeAll(@CheckForNull Object key) {
return delegate().removeAll(key);
Reported by PMD.
Line: 56
@Override
public SortedSet<V> removeAll(@CheckForNull Object key) {
return delegate().removeAll(key);
}
@Override
public SortedSet<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
return delegate().replaceValues(key, values);
Reported by PMD.
Line: 61
@Override
public SortedSet<V> replaceValues(@ParametricNullness K key, Iterable<? extends V> values) {
return delegate().replaceValues(key, values);
}
@Override
@CheckForNull
public Comparator<? super V> valueComparator() {
Reported by PMD.
Line: 67
@Override
@CheckForNull
public Comparator<? super V> valueComparator() {
return delegate().valueComparator();
}
}
Reported by PMD.
guava/src/com/google/common/util/concurrent/AtomicDoubleArray.java
4 issues
Line: 258
for (int i = 0; i < length; i++) {
builder.add(doubleToRawLongBits(s.readDouble()));
}
this.longs = new AtomicLongArray(builder.build().toArray());
}
}
Reported by PMD.
Line: 71
* @param array the array to copy elements from
* @throws NullPointerException if array is null
*/
public AtomicDoubleArray(double[] array) {
final int len = array.length;
long[] longArray = new long[len];
for (int i = 0; i < len; i++) {
longArray[i] = doubleToRawLongBits(array[i]);
}
Reported by PMD.
Line: 220
// Double.toString(Math.PI).length() == 17
StringBuilder b = new StringBuilder((17 + 2) * (iMax + 1));
b.append('[');
for (int i = 0; ; i++) {
b.append(longBitsToDouble(longs.get(i)));
if (i == iMax) {
return b.append(']').toString();
}
b.append(',').append(' ');
Reported by PMD.
Line: 220
// Double.toString(Math.PI).length() == 17
StringBuilder b = new StringBuilder((17 + 2) * (iMax + 1));
b.append('[');
for (int i = 0; ; i++) {
b.append(longBitsToDouble(longs.get(i)));
if (i == iMax) {
return b.append(']').toString();
}
b.append(',').append(' ');
Reported by PMD.
guava/src/com/google/common/collect/ForwardingConcurrentMap.java
4 issues
Line: 54
@Override
@CheckForNull
public V putIfAbsent(K key, V value) {
return delegate().putIfAbsent(key, value);
}
@CanIgnoreReturnValue
@Override
public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
Reported by PMD.
Line: 60
@CanIgnoreReturnValue
@Override
public boolean remove(@CheckForNull Object key, @CheckForNull Object value) {
return delegate().remove(key, value);
}
@CanIgnoreReturnValue
@Override
@CheckForNull
Reported by PMD.
Line: 67
@Override
@CheckForNull
public V replace(K key, V value) {
return delegate().replace(key, value);
}
@CanIgnoreReturnValue
@Override
public boolean replace(K key, V oldValue, V newValue) {
Reported by PMD.
Line: 73
@CanIgnoreReturnValue
@Override
public boolean replace(K key, V oldValue, V newValue) {
return delegate().replace(key, oldValue, newValue);
}
}
Reported by PMD.
guava/src/com/google/common/graph/ImmutableGraph.java
4 issues
Line: 51
@ElementTypesAreNonnullByDefault
public class ImmutableGraph<N> extends ForwardingGraph<N> {
@SuppressWarnings("Immutable") // The backing graph must be immutable.
private final BaseGraph<N> backingGraph;
ImmutableGraph(BaseGraph<N> backingGraph) {
this.backingGraph = backingGraph;
}
Reported by PMD.
Line: 63
? (ImmutableGraph<N>) graph
: new ImmutableGraph<N>(
new StandardValueGraph<N, Presence>(
GraphBuilder.from(graph), getNodeConnections(graph), graph.edges().size()));
}
/**
* Simply returns its argument.
*
Reported by PMD.
Line: 90
for (N node : graph.nodes()) {
nodeConnections.put(node, connectionsOf(graph, node));
}
return nodeConnections.build();
}
@SuppressWarnings("unchecked")
private static <N> GraphConnections<N, Presence> connectionsOf(Graph<N> graph, N node) {
Function<N, Presence> edgeValueFn =
Reported by PMD.
Line: 131
*/
public static class Builder<N> {
private final MutableGraph<N> mutableGraph;
Builder(GraphBuilder<N> graphBuilder) {
// The incidentEdgeOrder for immutable graphs is always stable. However, we don't want to
// modify this builder, so we make a copy instead.
this.mutableGraph = graphBuilder.copy().incidentEdgeOrder(ElementOrder.<N>stable()).build();
Reported by PMD.