The following issues were found
guava/src/com/google/common/collect/ImmutableBiMap.java
12 issues
Line: 46
*/
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class ImmutableBiMap<K, V> extends ImmutableBiMapFauxverideShim<K, V>
implements BiMap<K, V> {
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableBiMap} whose keys
* and values are the result of applying the provided mapping functions to the input elements.
Reported by PMD.
Line: 47
@GwtCompatible(serializable = true, emulated = true)
@ElementTypesAreNonnullByDefault
public abstract class ImmutableBiMap<K, V> extends ImmutableBiMapFauxverideShim<K, V>
implements BiMap<K, V> {
/**
* Returns a {@link Collector} that accumulates elements into an {@code ImmutableBiMap} whose keys
* and values are the result of applying the provided mapping functions to the input elements.
* Entries appear in the result {@code ImmutableBiMap} in encounter order.
Reported by PMD.
Line: 117
*
* @throws IllegalArgumentException if duplicate keys or values are added
*/
public static <K, V> ImmutableBiMap<K, V> of(
K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5) {
return RegularImmutableBiMap.fromEntries(
entryOf(k1, v1), entryOf(k2, v2), entryOf(k3, v3), entryOf(k4, v4), entryOf(k5, v5));
}
Reported by PMD.
Line: 283
case 1:
// requireNonNull is safe because the first `size` elements have been filled in.
Entry<K, V> onlyEntry = requireNonNull(entries[0]);
return of(onlyEntry.getKey(), onlyEntry.getValue());
default:
/*
* If entries is full, or if hash flooding is detected, then this implementation may end
* up using the entries array directly and writing over the entry objects with
* non-terminal entries, but this is safe; if this Builder is used further, it will grow
Reported by PMD.
Line: 283
case 1:
// requireNonNull is safe because the first `size` elements have been filled in.
Entry<K, V> onlyEntry = requireNonNull(entries[0]);
return of(onlyEntry.getKey(), onlyEntry.getValue());
default:
/*
* If entries is full, or if hash flooding is detected, then this implementation may end
* up using the entries array directly and writing over the entry objects with
* non-terminal entries, but this is safe; if this Builder is used further, it will grow
Reported by PMD.
Line: 300
entries,
0,
size,
Ordering.from(valueComparator).onResultOf(Maps.<V>valueFunction()));
}
entriesUsed = true;
return RegularImmutableBiMap.fromEntryArray(size, entries);
}
}
Reported by PMD.
Line: 319
case 1:
// requireNonNull is safe because the first `size` elements have been filled in.
Entry<K, V> onlyEntry = requireNonNull(entries[0]);
return of(onlyEntry.getKey(), onlyEntry.getValue());
default:
entriesUsed = true;
return RegularImmutableBiMap.fromEntryArray(size, entries);
}
}
Reported by PMD.
Line: 319
case 1:
// requireNonNull is safe because the first `size` elements have been filled in.
Entry<K, V> onlyEntry = requireNonNull(entries[0]);
return of(onlyEntry.getKey(), onlyEntry.getValue());
default:
entriesUsed = true;
return RegularImmutableBiMap.fromEntryArray(size, entries);
}
}
Reported by PMD.
Line: 349
ImmutableBiMap<K, V> bimap = (ImmutableBiMap<K, V>) map;
// TODO(lowasser): if we need to make a copy of a BiMap because the
// forward map is a view, don't make a copy of the non-view delegate map
if (!bimap.isPartialView()) {
return bimap;
}
}
return copyOf(map.entrySet());
}
Reported by PMD.
Line: 375
return of();
case 1:
Entry<K, V> entry = entryArray[0];
return of(entry.getKey(), entry.getValue());
default:
/*
* The current implementation will end up using entryArray directly, though it will write
* over the (arbitrary, potentially mutable) Entry objects actually stored in entryArray.
*/
Reported by PMD.
guava/src/com/google/common/hash/AbstractNonStreamingHashFunction.java
12 issues
Line: 48
@Override
public HashCode hashInt(int input) {
return hashBytes(ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(input).array());
}
@Override
public HashCode hashLong(long input) {
return hashBytes(ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(input).array());
Reported by PMD.
Line: 48
@Override
public HashCode hashInt(int input) {
return hashBytes(ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(input).array());
}
@Override
public HashCode hashLong(long input) {
return hashBytes(ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(input).array());
Reported by PMD.
Line: 48
@Override
public HashCode hashInt(int input) {
return hashBytes(ByteBuffer.allocate(4).order(ByteOrder.LITTLE_ENDIAN).putInt(input).array());
}
@Override
public HashCode hashLong(long input) {
return hashBytes(ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(input).array());
Reported by PMD.
Line: 53
@Override
public HashCode hashLong(long input) {
return hashBytes(ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(input).array());
}
@Override
public HashCode hashUnencodedChars(CharSequence input) {
int len = input.length();
Reported by PMD.
Line: 53
@Override
public HashCode hashLong(long input) {
return hashBytes(ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(input).array());
}
@Override
public HashCode hashUnencodedChars(CharSequence input) {
int len = input.length();
Reported by PMD.
Line: 53
@Override
public HashCode hashLong(long input) {
return hashBytes(ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(input).array());
}
@Override
public HashCode hashUnencodedChars(CharSequence input) {
int len = input.length();
Reported by PMD.
Line: 59
@Override
public HashCode hashUnencodedChars(CharSequence input) {
int len = input.length();
ByteBuffer buffer = ByteBuffer.allocate(len * 2).order(ByteOrder.LITTLE_ENDIAN);
for (int i = 0; i < len; i++) {
buffer.putChar(input.charAt(i));
}
return hashBytes(buffer.array());
}
Reported by PMD.
Line: 63
for (int i = 0; i < len; i++) {
buffer.putChar(input.charAt(i));
}
return hashBytes(buffer.array());
}
@Override
public HashCode hashString(CharSequence input, Charset charset) {
return hashBytes(input.toString().getBytes(charset));
Reported by PMD.
Line: 68
@Override
public HashCode hashString(CharSequence input, Charset charset) {
return hashBytes(input.toString().getBytes(charset));
}
@Override
public abstract HashCode hashBytes(byte[] input, int off, int len);
Reported by PMD.
Line: 76
@Override
public HashCode hashBytes(ByteBuffer input) {
return newHasher(input.remaining()).putBytes(input).hash();
}
/** In-memory stream-based implementation of Hasher. */
private final class BufferingHasher extends AbstractHasher {
final ExposedByteArrayOutputStream stream;
Reported by PMD.
guava/src/com/google/common/base/Suppliers.java
12 issues
Line: 56
private static class SupplierComposition<F extends @Nullable Object, T extends @Nullable Object>
implements Supplier<T>, Serializable {
final Function<? super F, T> function;
final Supplier<F> supplier;
SupplierComposition(Function<? super F, T> function, Supplier<F> supplier) {
this.function = checkNotNull(function);
this.supplier = checkNotNull(supplier);
Reported by PMD.
Line: 57
private static class SupplierComposition<F extends @Nullable Object, T extends @Nullable Object>
implements Supplier<T>, Serializable {
final Function<? super F, T> function;
final Supplier<F> supplier;
SupplierComposition(Function<? super F, T> function, Supplier<F> supplier) {
this.function = checkNotNull(function);
this.supplier = checkNotNull(supplier);
}
Reported by PMD.
Line: 120
@VisibleForTesting
static class MemoizingSupplier<T extends @Nullable Object> implements Supplier<T>, Serializable {
final Supplier<T> delegate;
transient volatile boolean initialized;
// "value" does not need to be volatile; visibility piggy-backs
// on volatile read of "initialized".
@CheckForNull transient T value;
Reported by PMD.
Line: 160
@VisibleForTesting
static class NonSerializableMemoizingSupplier<T extends @Nullable Object> implements Supplier<T> {
@CheckForNull volatile Supplier<T> delegate;
volatile boolean initialized;
// "value" does not need to be volatile; visibility piggy-backs
// on volatile read of "initialized".
@CheckForNull T value;
Reported by PMD.
Line: 161
@VisibleForTesting
static class NonSerializableMemoizingSupplier<T extends @Nullable Object> implements Supplier<T> {
@CheckForNull volatile Supplier<T> delegate;
volatile boolean initialized;
// "value" does not need to be volatile; visibility piggy-backs
// on volatile read of "initialized".
@CheckForNull T value;
NonSerializableMemoizingSupplier(Supplier<T> delegate) {
Reported by PMD.
Line: 164
volatile boolean initialized;
// "value" does not need to be volatile; visibility piggy-backs
// on volatile read of "initialized".
@CheckForNull T value;
NonSerializableMemoizingSupplier(Supplier<T> delegate) {
this.delegate = checkNotNull(delegate);
}
Reported by PMD.
Line: 183
* TODO(cpovirk): To avoid having to check for null, replace `delegate` with a singleton
* `Supplier` that always throws an exception.
*/
T t = requireNonNull(delegate).get();
value = t;
initialized = true;
// Release the delegate to GC.
delegate = null;
return t;
Reported by PMD.
Line: 187
value = t;
initialized = true;
// Release the delegate to GC.
delegate = null;
return t;
}
}
}
// This is safe because we checked `initialized.`
Reported by PMD.
Line: 236
@SuppressWarnings("GoodTime") // lots of violations
static class ExpiringMemoizingSupplier<T extends @Nullable Object>
implements Supplier<T>, Serializable {
final Supplier<T> delegate;
final long durationNanos;
@CheckForNull transient volatile T value;
// The special value 0 means "not yet initialized".
transient volatile long expirationNanos;
Reported by PMD.
Line: 237
static class ExpiringMemoizingSupplier<T extends @Nullable Object>
implements Supplier<T>, Serializable {
final Supplier<T> delegate;
final long durationNanos;
@CheckForNull transient volatile T value;
// The special value 0 means "not yet initialized".
transient volatile long expirationNanos;
ExpiringMemoizingSupplier(Supplier<T> delegate, long duration, TimeUnit unit) {
Reported by PMD.
guava/src/com/google/common/collect/Cut.java
12 issues
Line: 36
*/
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializable {
final C endpoint;
Cut(C endpoint) {
this.endpoint = endpoint;
}
Reported by PMD.
Line: 37
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializable {
final C endpoint;
Cut(C endpoint) {
this.endpoint = endpoint;
}
Reported by PMD.
Line: 37
@GwtCompatible
@ElementTypesAreNonnullByDefault
abstract class Cut<C extends Comparable> implements Comparable<Cut<C>>, Serializable {
final C endpoint;
Cut(C endpoint) {
this.endpoint = endpoint;
}
Reported by PMD.
Line: 123
private static final long serialVersionUID = 0;
private static final class BelowAll extends Cut<Comparable<?>> {
private static final BelowAll INSTANCE = new BelowAll();
private BelowAll() {
/*
* No code ever sees this bogus value for `endpoint`: This class overrides both methods that
Reported by PMD.
Line: 153
@Override
BoundType typeAsUpperBound() {
throw new AssertionError("this statement should be unreachable");
}
@Override
Cut<Comparable<?>> withLowerBoundType(
BoundType boundType, DiscreteDomain<Comparable<?>> domain) {
Reported by PMD.
Line: 199
@Override
public int compareTo(Cut<Comparable<?>> o) {
return (o == this) ? 0 : -1;
}
@Override
public int hashCode() {
return System.identityHashCode(this);
Reported by PMD.
Line: 228
return (Cut<C>) AboveAll.INSTANCE;
}
private static final class AboveAll extends Cut<Comparable<?>> {
private static final AboveAll INSTANCE = new AboveAll();
private AboveAll() {
// For discussion of "", see BelowAll.
super("");
Reported by PMD.
Line: 290
@Override
public int compareTo(Cut<Comparable<?>> o) {
return (o == this) ? 0 : 1;
}
@Override
public int hashCode() {
return System.identityHashCode(this);
Reported by PMD.
Line: 294
}
@Override
public int hashCode() {
return System.identityHashCode(this);
}
@Override
public String toString() {
Reported by PMD.
Line: 382
}
@Override
public int hashCode() {
return endpoint.hashCode();
}
@Override
public String toString() {
Reported by PMD.
guava/src/com/google/common/io/ByteSink.java
12 issues
Line: 102
Closer closer = Closer.create();
try {
OutputStream out = closer.register(openStream());
out.write(bytes);
out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
Reported by PMD.
Line: 103
Closer closer = Closer.create();
try {
OutputStream out = closer.register(openStream());
out.write(bytes);
out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
Reported by PMD.
Line: 104
try {
OutputStream out = closer.register(openStream());
out.write(bytes);
out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
Reported by PMD.
Line: 105
OutputStream out = closer.register(openStream());
out.write(bytes);
out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
}
Reported by PMD.
Line: 125
Closer closer = Closer.create();
try {
OutputStream out = closer.register(openStream());
long written = ByteStreams.copy(input, out);
out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
return written;
} catch (Throwable e) {
throw closer.rethrow(e);
Reported by PMD.
Line: 127
try {
OutputStream out = closer.register(openStream());
long written = ByteStreams.copy(input, out);
out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
return written;
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
Reported by PMD.
Line: 129
long written = ByteStreams.copy(input, out);
out.flush(); // https://code.google.com/p/guava-libraries/issues/detail?id=1330
return written;
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
}
Reported by PMD.
Line: 142
*/
private final class AsCharSink extends CharSink {
private final Charset charset;
private AsCharSink(Charset charset) {
this.charset = checkNotNull(charset);
}
Reported by PMD.
Line: 150
@Override
public Writer openStream() throws IOException {
return new OutputStreamWriter(ByteSink.this.openStream(), charset);
}
@Override
public String toString() {
return ByteSink.this.toString() + ".asCharSink(" + charset + ")";
Reported by PMD.
Line: 150
@Override
public Writer openStream() throws IOException {
return new OutputStreamWriter(ByteSink.this.openStream(), charset);
}
@Override
public String toString() {
return ByteSink.this.toString() + ".asCharSink(" + charset + ")";
Reported by PMD.
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/src/com/google/common/collect/EnumMultiset.java
11 issues
Line: 50
@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: 67
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: 87
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: 88
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: 101
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: 135
return 0;
}
Enum<?> e = (Enum<?>) element;
return counts[e.ordinal()];
}
// Modification Operations
@CanIgnoreReturnValue
@Override
Reported by PMD.
Line: 172
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: 213
}
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
Reported by PMD.
Line: 214
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.
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/src/com/google/common/collect/TreeTraverser.java
11 issues
Line: 132
@Override
public void accept(T t) {
action.accept(t);
children(t).forEach(this);
}
}.accept(root);
}
};
}
Reported by PMD.
Line: 144
}
private final class PreOrderIterator extends UnmodifiableIterator<T> {
private final Deque<Iterator<T>> stack;
PreOrderIterator(T root) {
this.stack = new ArrayDeque<>();
stack.addLast(Iterators.singletonIterator(checkNotNull(root)));
}
Reported by PMD.
Line: 163
if (!itr.hasNext()) {
stack.removeLast();
}
Iterator<T> childItr = children(result).iterator();
if (childItr.hasNext()) {
stack.addLast(childItr);
}
return result;
}
Reported by PMD.
Line: 196
new Consumer<T>() {
@Override
public void accept(T t) {
children(t).forEach(this);
action.accept(t);
}
}.accept(root);
}
};
Reported by PMD.
Line: 209
}
private static final class PostOrderNode<T> {
final T root;
final Iterator<T> childIterator;
PostOrderNode(T root, Iterator<T> childIterator) {
this.root = checkNotNull(root);
this.childIterator = checkNotNull(childIterator);
Reported by PMD.
Line: 210
private static final class PostOrderNode<T> {
final T root;
final Iterator<T> childIterator;
PostOrderNode(T root, Iterator<T> childIterator) {
this.root = checkNotNull(root);
this.childIterator = checkNotNull(childIterator);
}
Reported by PMD.
Line: 219
}
private final class PostOrderIterator extends AbstractIterator<T> {
private final ArrayDeque<PostOrderNode<T>> stack;
PostOrderIterator(T root) {
this.stack = new ArrayDeque<>();
stack.addLast(expand(root));
}
Reported by PMD.
Line: 231
protected T computeNext() {
while (!stack.isEmpty()) {
PostOrderNode<T> top = stack.getLast();
if (top.childIterator.hasNext()) {
T child = top.childIterator.next();
stack.addLast(expand(child));
} else {
stack.removeLast();
return top.root;
Reported by PMD.
Line: 232
while (!stack.isEmpty()) {
PostOrderNode<T> top = stack.getLast();
if (top.childIterator.hasNext()) {
T child = top.childIterator.next();
stack.addLast(expand(child));
} else {
stack.removeLast();
return top.root;
}
Reported by PMD.
Line: 243
}
private PostOrderNode<T> expand(T t) {
return new PostOrderNode<T>(t, children(t).iterator());
}
}
/**
* Returns an unmodifiable iterable over the nodes in a tree structure, using breadth-first
Reported by PMD.
guava/src/com/google/common/hash/Crc32cHashFunction.java
11 issues
Line: 364
^ STRIDE_TABLE[0][word >>> 24];
}
static int combine(int csum, int crc) {
csum ^= crc;
for (int i = 0; i < 4; i++) {
csum = (csum >>> 8) ^ BYTE_TABLE[csum & 0xFF];
}
return csum;
Reported by PMD.
Line: 364
^ STRIDE_TABLE[0][word >>> 24];
}
static int combine(int csum, int crc) {
csum ^= crc;
for (int i = 0; i < 4; i++) {
csum = (csum >>> 8) ^ BYTE_TABLE[csum & 0xFF];
}
return csum;
Reported by PMD.
Line: 63
super(16);
}
private boolean finished = false;
/*
* This trick allows us to avoid having separate states for "first four ints" and "all other
* four int chunks." The state we want after the first four bytes is
*
Reported by PMD.
Line: 63
super(16);
}
private boolean finished = false;
/*
* This trick allows us to avoid having separate states for "first four ints" and "all other
* four int chunks." The state we want after the first four bytes is
*
Reported by PMD.
Line: 77
* ...so we set crc0 so that computeForWord(crc0) = -1 and xoring it with the first int
* gives us the desired result. computeForWord(0) == 0, so all the others do the right thing.
*/
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
Reported by PMD.
Line: 78
* gives us the desired result. computeForWord(0) == 0, so all the others do the right thing.
*/
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
protected void process(ByteBuffer bb) {
Reported by PMD.
Line: 78
* gives us the desired result. computeForWord(0) == 0, so all the others do the right thing.
*/
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
protected void process(ByteBuffer bb) {
Reported by PMD.
Line: 79
*/
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
protected void process(ByteBuffer bb) {
if (finished) {
Reported by PMD.
Line: 79
*/
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
protected void process(ByteBuffer bb) {
if (finished) {
Reported by PMD.
Line: 80
private int crc0 = INVERSE_COMPUTE_FOR_WORD_OF_ALL_1S;
private int crc1 = 0;
private int crc2 = 0;
private int crc3 = 0;
@Override
protected void process(ByteBuffer bb) {
if (finished) {
throw new IllegalStateException(
Reported by PMD.