The following issues were found
guava/src/com/google/common/graph/ElementOrder.java
7 issues
Line: 50
@Beta
@Immutable
@ElementTypesAreNonnullByDefault
public final class ElementOrder<T> {
private final Type type;
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
@CheckForNull
private final Comparator<T> comparator;
Reported by PMD.
Line: 51
@Immutable
@ElementTypesAreNonnullByDefault
public final class ElementOrder<T> {
private final Type type;
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
@CheckForNull
private final Comparator<T> comparator;
Reported by PMD.
Line: 51
@Immutable
@ElementTypesAreNonnullByDefault
public final class ElementOrder<T> {
private final Type type;
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
@CheckForNull
private final Comparator<T> comparator;
Reported by PMD.
Line: 55
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
@CheckForNull
private final Comparator<T> comparator;
/**
* The type of ordering that this object specifies.
*
* <ul>
Reported by PMD.
Line: 55
@SuppressWarnings("Immutable") // Hopefully the comparator provided is immutable!
@CheckForNull
private final Comparator<T> comparator;
/**
* The type of ordering that this object specifies.
*
* <ul>
Reported by PMD.
Line: 183
@Override
public String toString() {
ToStringHelper helper = MoreObjects.toStringHelper(this).add("type", type);
if (comparator != null) {
helper.add("comparator", comparator);
}
return helper.toString();
}
Reported by PMD.
Line: 187
if (comparator != null) {
helper.add("comparator", comparator);
}
return helper.toString();
}
/** Returns an empty mutable map whose keys will respect this {@link ElementOrder}. */
<K extends T, V> Map<K, V> createMap(int expectedSize) {
switch (type) {
Reported by PMD.
guava/src/com/google/common/reflect/Parameter.java
7 issues
Line: 38
@ElementTypesAreNonnullByDefault
public final class Parameter implements AnnotatedElement {
private final Invokable<?, ?> declaration;
private final int position;
private final TypeToken<?> type;
private final ImmutableList<Annotation> annotations;
private final AnnotatedType annotatedType;
Reported by PMD.
Line: 39
public final class Parameter implements AnnotatedElement {
private final Invokable<?, ?> declaration;
private final int position;
private final TypeToken<?> type;
private final ImmutableList<Annotation> annotations;
private final AnnotatedType annotatedType;
Parameter(
Reported by PMD.
Line: 109
@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
@Override
Reported by PMD.
Line: 109
@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
@Override
Reported by PMD.
Line: 109
@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
@Override
Reported by PMD.
Line: 117
@Override
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: 117
@Override
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.
guava/src/com/google/common/collect/MutableClassToInstanceMap.java
7 issues
Line: 65
return new MutableClassToInstanceMap<B>(backingMap);
}
private final Map<Class<? extends B>, B> delegate;
private MutableClassToInstanceMap(Map<Class<? extends B>, B> delegate) {
this.delegate = checkNotNull(delegate);
}
Reported by PMD.
Line: 100
@Override
protected Set<Entry<Class<? extends B>, B>> delegate() {
return MutableClassToInstanceMap.this.delegate().entrySet();
}
@Override
public Spliterator<Entry<Class<? extends B>, B>> spliterator() {
return CollectSpliterators.map(
Reported by PMD.
Line: 100
@Override
protected Set<Entry<Class<? extends B>, B>> delegate() {
return MutableClassToInstanceMap.this.delegate().entrySet();
}
@Override
public Spliterator<Entry<Class<? extends B>, B>> spliterator() {
return CollectSpliterators.map(
Reported by PMD.
Line: 100
@Override
protected Set<Entry<Class<? extends B>, B>> delegate() {
return MutableClassToInstanceMap.this.delegate().entrySet();
}
@Override
public Spliterator<Entry<Class<? extends B>, B>> spliterator() {
return CollectSpliterators.map(
Reported by PMD.
Line: 106
@Override
public Spliterator<Entry<Class<? extends B>, B>> spliterator() {
return CollectSpliterators.map(
delegate().spliterator(), MutableClassToInstanceMap::checkedEntry);
}
@Override
public Iterator<Entry<Class<? extends B>, B>> iterator() {
return new TransformedIterator<Entry<Class<? extends B>, B>, Entry<Class<? extends B>, B>>(
Reported by PMD.
Line: 112
@Override
public Iterator<Entry<Class<? extends B>, B>> iterator() {
return new TransformedIterator<Entry<Class<? extends B>, B>, Entry<Class<? extends B>, B>>(
delegate().iterator()) {
@Override
Entry<Class<? extends B>, B> transform(Entry<Class<? extends B>, B> from) {
return checkedEntry(from);
}
};
Reported by PMD.
Line: 160
@CanIgnoreReturnValue
private static <B, T extends B> T cast(Class<T> type, B value) {
return Primitives.wrap(type).cast(value);
}
private Object writeReplace() {
return new SerializedForm(delegate());
}
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/ClassPathUtil.java
7 issues
Line: 39
// TODO(b/65488446): Make this a public API.
static URL[] parseJavaClassPath() {
ImmutableList.Builder<URL> urls = ImmutableList.builder();
for (String entry : Splitter.on(PATH_SEPARATOR.value()).split(JAVA_CLASS_PATH.value())) {
try {
try {
urls.add(new File(entry).toURI().toURL());
} catch (SecurityException e) { // File.toURI checks to see if the file is a directory
urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
Reported by PMD.
Line: 42
for (String entry : Splitter.on(PATH_SEPARATOR.value()).split(JAVA_CLASS_PATH.value())) {
try {
try {
urls.add(new File(entry).toURI().toURL());
} catch (SecurityException e) { // File.toURI checks to see if the file is a directory
urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
}
} catch (MalformedURLException e) {
AssertionError error = new AssertionError("malformed class path entry: " + entry);
Reported by PMD.
Line: 44
try {
urls.add(new File(entry).toURI().toURL());
} catch (SecurityException e) { // File.toURI checks to see if the file is a directory
urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
}
} catch (MalformedURLException e) {
AssertionError error = new AssertionError("malformed class path entry: " + entry);
error.initCause(e);
throw error;
Reported by PMD.
Line: 44
try {
urls.add(new File(entry).toURI().toURL());
} catch (SecurityException e) { // File.toURI checks to see if the file is a directory
urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
}
} catch (MalformedURLException e) {
AssertionError error = new AssertionError("malformed class path entry: " + entry);
error.initCause(e);
throw error;
Reported by PMD.
Line: 47
urls.add(new URL("file", null, new File(entry).getAbsolutePath()));
}
} catch (MalformedURLException e) {
AssertionError error = new AssertionError("malformed class path entry: " + entry);
error.initCause(e);
throw error;
}
}
return urls.build().toArray(new URL[0]);
Reported by PMD.
Line: 57
/** Returns the URLs in the class path. */
static URL[] getClassPathUrls() {
return ClassPathUtil.class.getClassLoader() instanceof URLClassLoader
? ((URLClassLoader) ClassPathUtil.class.getClassLoader()).getURLs()
: parseJavaClassPath();
}
}
Reported by PMD.
Line: 58
/** Returns the URLs in the class path. */
static URL[] getClassPathUrls() {
return ClassPathUtil.class.getClassLoader() instanceof URLClassLoader
? ((URLClassLoader) ClassPathUtil.class.getClassLoader()).getURLs()
: parseJavaClassPath();
}
}
Reported by PMD.
guava/src/com/google/common/util/concurrent/JdkFutureAdapters.java
7 issues
Line: 111
private static final Executor defaultAdapterExecutor =
Executors.newCachedThreadPool(threadFactory);
private final Executor adapterExecutor;
// The execution list to hold our listeners.
private final ExecutionList executionList = new ExecutionList();
// This allows us to only start up a thread waiting on the delegate future when the first
Reported by PMD.
Line: 114
private final Executor adapterExecutor;
// The execution list to hold our listeners.
private final ExecutionList executionList = new ExecutionList();
// This allows us to only start up a thread waiting on the delegate future when the first
// listener is added.
private final AtomicBoolean hasListeners = new AtomicBoolean(false);
Reported by PMD.
Line: 118
// This allows us to only start up a thread waiting on the delegate future when the first
// listener is added.
private final AtomicBoolean hasListeners = new AtomicBoolean(false);
// The delegate future.
private final Future<V> delegate;
ListenableFutureAdapter(Future<V> delegate) {
Reported by PMD.
Line: 121
private final AtomicBoolean hasListeners = new AtomicBoolean(false);
// The delegate future.
private final Future<V> delegate;
ListenableFutureAdapter(Future<V> delegate) {
this(delegate, defaultAdapterExecutor);
}
Reported by PMD.
Line: 121
private final AtomicBoolean hasListeners = new AtomicBoolean(false);
// The delegate future.
private final Future<V> delegate;
ListenableFutureAdapter(Future<V> delegate) {
this(delegate, defaultAdapterExecutor);
}
Reported by PMD.
Line: 163
* to return a proper ListenableFuture instead of using listenInPoolThread.
*/
getUninterruptibly(delegate);
} catch (Throwable e) {
// ExecutionException / CancellationException / RuntimeException / Error
// The task is presumably done, run the listeners.
}
executionList.execute();
}
Reported by PMD.
Line: 163
* to return a proper ListenableFuture instead of using listenInPoolThread.
*/
getUninterruptibly(delegate);
} catch (Throwable e) {
// ExecutionException / CancellationException / RuntimeException / Error
// The task is presumably done, run the listeners.
}
executionList.execute();
}
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/AbstractFutureBenchmarks.java
7 issues
Line: 107
abstract static class OldAbstractFuture<V> implements ListenableFuture<V> {
/** Synchronization control for AbstractFutures. */
private final Sync<V> sync = new Sync<V>();
// The execution list to hold our executors.
private final ExecutionList executionList = new ExecutionList();
/** Constructor for use by subclasses. */
Reported by PMD.
Line: 110
private final Sync<V> sync = new Sync<V>();
// The execution list to hold our executors.
private final ExecutionList executionList = new ExecutionList();
/** Constructor for use by subclasses. */
protected OldAbstractFuture() {}
/*
Reported by PMD.
Line: 272
static final int CANCELLED = 4;
static final int INTERRUPTED = 8;
private V value;
private Throwable exception;
/*
* Acquisition succeeds if the future is done, otherwise it fails.
*/
Reported by PMD.
Line: 273
static final int INTERRUPTED = 8;
private V value;
private Throwable exception;
/*
* Acquisition succeeds if the future is done, otherwise it fails.
*/
@Override
Reported by PMD.
Line: 301
* if the timer expires, otherwise behaves like {@link #get()}.
*/
V get(long nanos)
throws TimeoutException, CancellationException, ExecutionException, InterruptedException {
// Attempt to acquire the shared lock with a timeout.
if (!tryAcquireSharedNanos(-1, nanos)) {
throw new TimeoutException("Timeout waiting for task.");
}
Reported by PMD.
Line: 316
* a {@link CancellationException} if the task was cancelled, or a {@link ExecutionException}
* if the task completed with an error.
*/
V get() throws CancellationException, ExecutionException, InterruptedException {
// Acquire the shared lock allowing interruption.
acquireSharedInterruptibly(-1);
return getValue();
}
Reported by PMD.
Line: 328
* exception on failure, a cancellation on cancellation, or an illegal state if the
* synchronizer is in an invalid state.
*/
private V getValue() throws CancellationException, ExecutionException {
int state = getState();
switch (state) {
case COMPLETED:
if (exception != null) {
throw new ExecutionException(exception);
Reported by PMD.
guava/src/com/google/common/hash/AbstractStreamingHasher.java
7 issues
Line: 33
// TODO(kevinb): this class still needs some design-and-document-for-inheritance love
@CanIgnoreReturnValue
@ElementTypesAreNonnullByDefault
abstract class AbstractStreamingHasher extends AbstractHasher {
/** Buffer via which we pass data to the hash algorithm (the implementor) */
private final ByteBuffer buffer;
/** Number of bytes to be filled before process() invocation(s). */
private final int bufferSize;
Reported by PMD.
Line: 35
@ElementTypesAreNonnullByDefault
abstract class AbstractStreamingHasher extends AbstractHasher {
/** Buffer via which we pass data to the hash algorithm (the implementor) */
private final ByteBuffer buffer;
/** Number of bytes to be filled before process() invocation(s). */
private final int bufferSize;
/** Number of bytes processed per process() invocation. */
Reported by PMD.
Line: 38
private final ByteBuffer buffer;
/** Number of bytes to be filled before process() invocation(s). */
private final int bufferSize;
/** Number of bytes processed per process() invocation. */
private final int chunkSize;
/**
Reported by PMD.
Line: 41
private final int bufferSize;
/** Number of bytes processed per process() invocation. */
private final int chunkSize;
/**
* Constructor for use by subclasses. This hasher instance will process chunks of the specified
* size.
*
Reported by PMD.
Line: 96
@Override
public final Hasher putBytes(byte[] bytes, int off, int len) {
return putBytesInternal(ByteBuffer.wrap(bytes, off, len).order(ByteOrder.LITTLE_ENDIAN));
}
@Override
public final Hasher putBytes(ByteBuffer readBuffer) {
ByteOrder order = readBuffer.order();
Reported by PMD.
Line: 200
// Process pent-up data in chunks
private void munchIfFull() {
if (buffer.remaining() < 8) {
// buffer is full; not enough room for a primitive. We have at least one full chunk.
munch();
}
}
Reported by PMD.
Line: 101
@Override
public final Hasher putBytes(ByteBuffer readBuffer) {
ByteOrder order = readBuffer.order();
try {
readBuffer.order(ByteOrder.LITTLE_ENDIAN);
return putBytesInternal(readBuffer);
} finally {
readBuffer.order(order);
Reported by PMD.
guava/src/com/google/common/io/LineReader.java
7 issues
Line: 42
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class LineReader {
private final Readable readable;
@CheckForNull private final Reader reader;
private final CharBuffer cbuf = createBuffer();
private final char[] buf = cbuf.array();
private final Queue<String> lines = new ArrayDeque<>();
Reported by PMD.
Line: 43
@ElementTypesAreNonnullByDefault
public final class LineReader {
private final Readable readable;
@CheckForNull private final Reader reader;
private final CharBuffer cbuf = createBuffer();
private final char[] buf = cbuf.array();
private final Queue<String> lines = new ArrayDeque<>();
private final LineBuffer lineBuf =
Reported by PMD.
Line: 44
public final class LineReader {
private final Readable readable;
@CheckForNull private final Reader reader;
private final CharBuffer cbuf = createBuffer();
private final char[] buf = cbuf.array();
private final Queue<String> lines = new ArrayDeque<>();
private final LineBuffer lineBuf =
new LineBuffer() {
Reported by PMD.
Line: 45
private final Readable readable;
@CheckForNull private final Reader reader;
private final CharBuffer cbuf = createBuffer();
private final char[] buf = cbuf.array();
private final Queue<String> lines = new ArrayDeque<>();
private final LineBuffer lineBuf =
new LineBuffer() {
@Override
Reported by PMD.
Line: 47
private final CharBuffer cbuf = createBuffer();
private final char[] buf = cbuf.array();
private final Queue<String> lines = new ArrayDeque<>();
private final LineBuffer lineBuf =
new LineBuffer() {
@Override
protected void handleLine(String line, String end) {
lines.add(line);
Reported by PMD.
Line: 48
private final char[] buf = cbuf.array();
private final Queue<String> lines = new ArrayDeque<>();
private final LineBuffer lineBuf =
new LineBuffer() {
@Override
protected void handleLine(String line, String end) {
lines.add(line);
}
Reported by PMD.
Line: 59
/** Creates a new instance that will read lines from the given {@code Readable} object. */
public LineReader(Readable readable) {
this.readable = checkNotNull(readable);
this.reader = (readable instanceof Reader) ? (Reader) readable : null;
}
/**
* Reads a line of text. A line is considered to be terminated by any one of a line feed ({@code
* '\n'}), a carriage return ({@code '\r'}), or a carriage return followed immediately by a
Reported by PMD.
guava/src/com/google/common/util/concurrent/ForwardingFuture.java
7 issues
Line: 50
@Override
public boolean cancel(boolean mayInterruptIfRunning) {
return delegate().cancel(mayInterruptIfRunning);
}
@Override
public boolean isCancelled() {
return delegate().isCancelled();
Reported by PMD.
Line: 55
@Override
public boolean isCancelled() {
return delegate().isCancelled();
}
@Override
public boolean isDone() {
return delegate().isDone();
Reported by PMD.
Line: 60
@Override
public boolean isDone() {
return delegate().isDone();
}
@Override
@ParametricNullness
public V get() throws InterruptedException, ExecutionException {
Reported by PMD.
Line: 66
@Override
@ParametricNullness
public V get() throws InterruptedException, ExecutionException {
return delegate().get();
}
@Override
@ParametricNullness
public V get(long timeout, TimeUnit unit)
Reported by PMD.
Line: 73
@ParametricNullness
public V get(long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
return delegate().get(timeout, unit);
}
// TODO(cpovirk): Use standard Javadoc form for SimpleForwarding* class and constructor
/**
* A simplified version of {@link ForwardingFuture} where subclasses can pass in an already
Reported by PMD.
Line: 85
*/
public abstract static class SimpleForwardingFuture<V extends @Nullable Object>
extends ForwardingFuture<V> {
private final Future<V> delegate;
protected SimpleForwardingFuture(Future<V> delegate) {
this.delegate = Preconditions.checkNotNull(delegate);
}
Reported by PMD.
Line: 85
*/
public abstract static class SimpleForwardingFuture<V extends @Nullable Object>
extends ForwardingFuture<V> {
private final Future<V> delegate;
protected SimpleForwardingFuture(Future<V> delegate) {
this.delegate = Preconditions.checkNotNull(delegate);
}
Reported by PMD.
guava/src/com/google/common/base/Stopwatch.java
7 issues
Line: 93
@GwtCompatible(emulated = true)
@SuppressWarnings("GoodTime") // lots of violations
@ElementTypesAreNonnullByDefault
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
Reported by PMD.
Line: 94
@SuppressWarnings("GoodTime") // lots of violations
@ElementTypesAreNonnullByDefault
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
Reported by PMD.
Line: 95
@ElementTypesAreNonnullByDefault
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
* Creates (but does not start) a new stopwatch using {@link System#nanoTime} as its time source.
Reported by PMD.
Line: 95
@ElementTypesAreNonnullByDefault
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
* Creates (but does not start) a new stopwatch using {@link System#nanoTime} as its time source.
Reported by PMD.
Line: 96
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
* Creates (but does not start) a new stopwatch using {@link System#nanoTime} as its time source.
*
Reported by PMD.
Line: 96
public final class Stopwatch {
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
* Creates (but does not start) a new stopwatch using {@link System#nanoTime} as its time source.
*
Reported by PMD.
Line: 97
private final Ticker ticker;
private boolean isRunning;
private long elapsedNanos;
private long startTick;
/**
* Creates (but does not start) a new stopwatch using {@link System#nanoTime} as its time source.
*
* @since 15.0
Reported by PMD.