The following issues were found
guava/src/com/google/common/util/concurrent/AbstractTransformFuture.java
18 issues
Line: 59
* In certain circumstances, this field might theoretically not be visible to an afterDone() call
* triggered by cancel(). For details, see the comments on the fields of TimeoutFuture.
*/
@CheckForNull ListenableFuture<? extends I> inputFuture;
@CheckForNull F function;
AbstractTransformFuture(ListenableFuture<? extends I> inputFuture, F function) {
this.inputFuture = checkNotNull(inputFuture);
this.function = checkNotNull(function);
Reported by PMD.
Line: 60
* triggered by cancel(). For details, see the comments on the fields of TimeoutFuture.
*/
@CheckForNull ListenableFuture<? extends I> inputFuture;
@CheckForNull F function;
AbstractTransformFuture(ListenableFuture<? extends I> inputFuture, F function) {
this.inputFuture = checkNotNull(inputFuture);
this.function = checkNotNull(function);
}
Reported by PMD.
Line: 68
}
@Override
public final void run() {
ListenableFuture<? extends I> localInputFuture = inputFuture;
F localFunction = function;
if (isCancelled() | localInputFuture == null | localFunction == null) {
return;
}
Reported by PMD.
Line: 74
if (isCancelled() | localInputFuture == null | localFunction == null) {
return;
}
inputFuture = null;
if (localInputFuture.isCancelled()) {
@SuppressWarnings("unchecked")
boolean unused =
setFuture((ListenableFuture<O>) localInputFuture); // Respects cancellation cause setting
Reported by PMD.
Line: 76
}
inputFuture = null;
if (localInputFuture.isCancelled()) {
@SuppressWarnings("unchecked")
boolean unused =
setFuture((ListenableFuture<O>) localInputFuture); // Respects cancellation cause setting
return;
}
Reported by PMD.
Line: 78
if (localInputFuture.isCancelled()) {
@SuppressWarnings("unchecked")
boolean unused =
setFuture((ListenableFuture<O>) localInputFuture); // Respects cancellation cause setting
return;
}
/*
Reported by PMD.
Line: 106
// Set the cause of the exception as this future's exception.
setException(e.getCause());
return;
} catch (RuntimeException e) {
// Bug in inputFuture.get(). Propagate to the output Future so that its consumers don't hang.
setException(e);
return;
} catch (Error e) {
/*
Reported by PMD.
Line: 123
T transformResult;
try {
transformResult = doTransform(localFunction, sourceResult);
} catch (Throwable t) {
// This exception is irrelevant in this thread, but useful for the client.
setException(t);
return;
} finally {
function = null;
Reported by PMD.
Line: 128
setException(t);
return;
} finally {
function = null;
}
/*
* If set()/setValue() throws an Error, we let it propagate. Why? The most likely Error is a
* StackOverflowError (from deep transform(..., directExecutor()) nesting), and calling
Reported by PMD.
Line: 173
/** Template method for subtypes to actually run the transform. */
@ForOverride
@ParametricNullness
abstract T doTransform(F function, @ParametricNullness I result) throws Exception;
/** Template method for subtypes to actually set the result. */
@ForOverride
abstract void setResult(@ParametricNullness T result);
Reported by PMD.
guava/src/com/google/common/graph/AbstractBaseGraph.java
18 issues
Line: 95
}
EndpointPair<?> endpointPair = (EndpointPair<?>) obj;
return isOrderingCompatible(endpointPair)
&& nodes().contains(endpointPair.nodeU())
&& successors((N) endpointPair.nodeU()).contains(endpointPair.nodeV());
}
};
}
Reported by PMD.
Line: 95
}
EndpointPair<?> endpointPair = (EndpointPair<?>) obj;
return isOrderingCompatible(endpointPair)
&& nodes().contains(endpointPair.nodeU())
&& successors((N) endpointPair.nodeU()).contains(endpointPair.nodeV());
}
};
}
Reported by PMD.
Line: 96
EndpointPair<?> endpointPair = (EndpointPair<?>) obj;
return isOrderingCompatible(endpointPair)
&& nodes().contains(endpointPair.nodeU())
&& successors((N) endpointPair.nodeU()).contains(endpointPair.nodeV());
}
};
}
@Override
Reported by PMD.
Line: 96
EndpointPair<?> endpointPair = (EndpointPair<?>) obj;
return isOrderingCompatible(endpointPair)
&& nodes().contains(endpointPair.nodeU())
&& successors((N) endpointPair.nodeU()).contains(endpointPair.nodeV());
}
};
}
@Override
Reported by PMD.
Line: 109
@Override
public Set<EndpointPair<N>> incidentEdges(N node) {
checkNotNull(node);
checkArgument(nodes().contains(node), "Node %s is not an element of this graph.", node);
return new IncidentEdgeSet<N>(this, node) {
@Override
public UnmodifiableIterator<EndpointPair<N>> iterator() {
if (graph.isDirected()) {
return Iterators.unmodifiableIterator(
Reported by PMD.
Line: 117
return Iterators.unmodifiableIterator(
Iterators.concat(
Iterators.transform(
graph.predecessors(node).iterator(),
new Function<N, EndpointPair<N>>() {
@Override
public EndpointPair<N> apply(N predecessor) {
return EndpointPair.ordered(predecessor, node);
}
Reported by PMD.
Line: 126
}),
Iterators.transform(
// filter out 'node' from successors (already covered by predecessors, above)
Sets.difference(graph.successors(node), ImmutableSet.of(node)).iterator(),
new Function<N, EndpointPair<N>>() {
@Override
public EndpointPair<N> apply(N successor) {
return EndpointPair.ordered(node, successor);
}
Reported by PMD.
Line: 136
} else {
return Iterators.unmodifiableIterator(
Iterators.transform(
graph.adjacentNodes(node).iterator(),
new Function<N, EndpointPair<N>>() {
@Override
public EndpointPair<N> apply(N adjacentNode) {
return EndpointPair.unordered(node, adjacentNode);
}
Reported by PMD.
Line: 151
@Override
public int degree(N node) {
if (isDirected()) {
return IntMath.saturatedAdd(predecessors(node).size(), successors(node).size());
} else {
Set<N> neighbors = adjacentNodes(node);
int selfLoopCount = (allowsSelfLoops() && neighbors.contains(node)) ? 1 : 0;
return IntMath.saturatedAdd(neighbors.size(), selfLoopCount);
}
Reported by PMD.
Line: 151
@Override
public int degree(N node) {
if (isDirected()) {
return IntMath.saturatedAdd(predecessors(node).size(), successors(node).size());
} else {
Set<N> neighbors = adjacentNodes(node);
int selfLoopCount = (allowsSelfLoops() && neighbors.contains(node)) ? 1 : 0;
return IntMath.saturatedAdd(neighbors.size(), selfLoopCount);
}
Reported by PMD.
guava/src/com/google/common/collect/TreeBasedTable.java
18 issues
Line: 190
this.lowerBound = lowerBound;
this.upperBound = upperBound;
checkArgument(
lowerBound == null || upperBound == null || compare(lowerBound, upperBound) <= 0);
}
@Override
public SortedSet<C> keySet() {
return new Maps.SortedKeySet<>(this);
Reported by PMD.
Line: 72
@GwtCompatible(serializable = true)
@ElementTypesAreNonnullByDefault
public class TreeBasedTable<R, C, V> extends StandardRowSortedTable<R, C, V> {
private final Comparator<? super C> columnComparator;
private static class Factory<C, V> implements Supplier<TreeMap<C, V>>, Serializable {
final Comparator<? super C> comparator;
Factory(Comparator<? super C> comparator) {
Reported by PMD.
Line: 72
@GwtCompatible(serializable = true)
@ElementTypesAreNonnullByDefault
public class TreeBasedTable<R, C, V> extends StandardRowSortedTable<R, C, V> {
private final Comparator<? super C> columnComparator;
private static class Factory<C, V> implements Supplier<TreeMap<C, V>>, Serializable {
final Comparator<? super C> comparator;
Factory(Comparator<? super C> comparator) {
Reported by PMD.
Line: 75
private final Comparator<? super C> columnComparator;
private static class Factory<C, V> implements Supplier<TreeMap<C, V>>, Serializable {
final Comparator<? super C> comparator;
Factory(Comparator<? super C> comparator) {
this.comparator = comparator;
}
Reported by PMD.
Line: 144
* requireNonNull is safe because the factories require non-null Comparators, which they pass on
* to the backing collections.
*/
return requireNonNull(rowKeySet().comparator());
}
/**
* Returns the comparator that orders the columns. With natural ordering, {@link
* Ordering#natural()} is returned.
Reported by PMD.
Line: 177
return new TreeRow(rowKey);
}
private class TreeRow extends Row implements SortedMap<C, V> {
@CheckForNull final C lowerBound;
@CheckForNull final C upperBound;
TreeRow(R rowKey) {
this(rowKey, null, null);
Reported by PMD.
Line: 178
}
private class TreeRow extends Row implements SortedMap<C, V> {
@CheckForNull final C lowerBound;
@CheckForNull final C upperBound;
TreeRow(R rowKey) {
this(rowKey, null, null);
}
Reported by PMD.
Line: 179
private class TreeRow extends Row implements SortedMap<C, V> {
@CheckForNull final C lowerBound;
@CheckForNull final C upperBound;
TreeRow(R rowKey) {
this(rowKey, null, null);
}
Reported by PMD.
Line: 207
// pretend we can compare anything
@SuppressWarnings("unchecked")
Comparator<Object> cmp = (Comparator<Object>) comparator();
return cmp.compare(a, b);
}
boolean rangeContains(@CheckForNull Object o) {
return o != null
&& (lowerBound == null || compare(lowerBound, o) <= 0)
Reported by PMD.
Line: 283
updateWholeRowField();
if (wholeRow != null && wholeRow.isEmpty()) {
backingMap.remove(rowKey);
wholeRow = null;
backingRowMap = null;
}
}
@Override
Reported by PMD.
guava/src/com/google/common/collect/ObjectArrays.java
17 issues
Line: 229
@CanIgnoreReturnValue
static Object checkElementNotNull(Object element, int index) {
if (element == null) {
throw new NullPointerException("at index " + index);
}
return element;
}
}
Reported by PMD.
Line: 128
* @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: 153
* <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: 37
*/
@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: 136
fillArray(c, array);
if (array.length > size) {
@Nullable Object[] unsoundlyCovariantArray = array;
unsoundlyCovariantArray[size] = null;
}
return array;
}
/**
Reported by PMD.
Line: 159
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: 86
* @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: 128
* @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: 153
* <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: 196
}
@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.
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.
guava/src/com/google/common/collect/CartesianList.java
17 issues
Line: 43
ImmutableList.Builder<List<E>> axesBuilder = new ImmutableList.Builder<>(lists.size());
for (List<? extends E> list : lists) {
List<E> copy = ImmutableList.copyOf(list);
if (copy.isEmpty()) {
return ImmutableList.of();
}
axesBuilder.add(copy);
}
return new CartesianList<E>(axesBuilder.build());
Reported by PMD.
Line: 60
axesSizeProduct[i] = IntMath.checkedMultiply(axesSizeProduct[i + 1], axes.get(i).size());
}
} catch (ArithmeticException e) {
throw new IllegalArgumentException(
"Cartesian product too large; must have size at most Integer.MAX_VALUE");
}
this.axesSizeProduct = axesSizeProduct;
}
Reported by PMD.
Line: 67
}
private int getAxisIndexForProductIndex(int index, int axis) {
return (index / axesSizeProduct[axis + 1]) % axes.get(axis).size();
}
@Override
public int indexOf(@CheckForNull Object o) {
if (!(o instanceof List)) {
Reported by PMD.
Line: 76
return -1;
}
List<?> list = (List<?>) o;
if (list.size() != axes.size()) {
return -1;
}
ListIterator<?> itr = list.listIterator();
int computedIndex = 0;
while (itr.hasNext()) {
Reported by PMD.
Line: 79
if (list.size() != axes.size()) {
return -1;
}
ListIterator<?> itr = list.listIterator();
int computedIndex = 0;
while (itr.hasNext()) {
int axisIndex = itr.nextIndex();
int elemIndex = axes.get(axisIndex).indexOf(itr.next());
if (elemIndex == -1) {
Reported by PMD.
Line: 83
int computedIndex = 0;
while (itr.hasNext()) {
int axisIndex = itr.nextIndex();
int elemIndex = axes.get(axisIndex).indexOf(itr.next());
if (elemIndex == -1) {
return -1;
}
computedIndex += elemIndex * axesSizeProduct[axisIndex + 1];
}
Reported by PMD.
Line: 98
return -1;
}
List<?> list = (List<?>) o;
if (list.size() != axes.size()) {
return -1;
}
ListIterator<?> itr = list.listIterator();
int computedIndex = 0;
while (itr.hasNext()) {
Reported by PMD.
Line: 101
if (list.size() != axes.size()) {
return -1;
}
ListIterator<?> itr = list.listIterator();
int computedIndex = 0;
while (itr.hasNext()) {
int axisIndex = itr.nextIndex();
int elemIndex = axes.get(axisIndex).lastIndexOf(itr.next());
if (elemIndex == -1) {
Reported by PMD.
Line: 105
int computedIndex = 0;
while (itr.hasNext()) {
int axisIndex = itr.nextIndex();
int elemIndex = axes.get(axisIndex).lastIndexOf(itr.next());
if (elemIndex == -1) {
return -1;
}
computedIndex += elemIndex * axesSizeProduct[axisIndex + 1];
}
Reported by PMD.
Line: 128
public E get(int axis) {
checkElementIndex(axis, size());
int axisIndex = getAxisIndexForProductIndex(index, axis);
return axes.get(axis).get(axisIndex);
}
@Override
boolean isPartialView() {
return true;
Reported by PMD.
guava/src/com/google/common/io/Closer.java
17 issues
Line: 153
checkNotNull(e);
thrown = e;
Throwables.propagateIfPossible(e, IOException.class);
throw new RuntimeException(e);
}
/**
* Stores the given throwable and rethrows it. It will be rethrown as is if it is an {@code
* IOException}, {@code RuntimeException}, {@code Error} or a checked exception of the given type.
Reported by PMD.
Line: 176
thrown = e;
Throwables.propagateIfPossible(e, IOException.class);
Throwables.propagateIfPossible(e, declaredType);
throw new RuntimeException(e);
}
/**
* Stores the given throwable and rethrows it. It will be rethrown as is if it is an {@code
* IOException}, {@code RuntimeException}, {@code Error} or a checked exception of either of the
Reported by PMD.
Line: 200
thrown = e;
Throwables.propagateIfPossible(e, IOException.class);
Throwables.propagateIfPossible(e, declaredType1, declaredType2);
throw new RuntimeException(e);
}
/**
* Closes all {@code Closeable} instances that have been added to this {@code Closer}. If an
* exception was thrown in the try block and passed to one of the {@code exceptionThrown} methods,
Reported by PMD.
Line: 254
@Override
public void suppress(Closeable closeable, Throwable thrown, Throwable suppressed) {
// log to the same place as Closeables
Closeables.logger.log(
Level.WARNING, "Suppressing exception thrown when closing " + closeable, suppressed);
}
}
/**
Reported by PMD.
Line: 108
return new Closer(SUPPRESSOR);
}
@VisibleForTesting final Suppressor suppressor;
// only need space for 2 elements in most cases, so try to use the smallest array possible
private final Deque<Closeable> stack = new ArrayDeque<>(4);
@CheckForNull private Throwable thrown;
Reported by PMD.
Line: 111
@VisibleForTesting final Suppressor suppressor;
// only need space for 2 elements in most cases, so try to use the smallest array possible
private final Deque<Closeable> stack = new ArrayDeque<>(4);
@CheckForNull private Throwable thrown;
@VisibleForTesting
Closer(Suppressor suppressor) {
this.suppressor = checkNotNull(suppressor); // checkNotNull to satisfy null tests
Reported by PMD.
Line: 112
// only need space for 2 elements in most cases, so try to use the smallest array possible
private final Deque<Closeable> stack = new ArrayDeque<>(4);
@CheckForNull private Throwable thrown;
@VisibleForTesting
Closer(Suppressor suppressor) {
this.suppressor = checkNotNull(suppressor); // checkNotNull to satisfy null tests
}
Reported by PMD.
Line: 216
// close closeables in LIFO order
while (!stack.isEmpty()) {
Closeable closeable = stack.removeFirst();
try {
closeable.close();
} catch (Throwable e) {
if (throwable == null) {
throwable = e;
Reported by PMD.
Line: 218
while (!stack.isEmpty()) {
Closeable closeable = stack.removeFirst();
try {
closeable.close();
} catch (Throwable e) {
if (throwable == null) {
throwable = e;
} else {
suppressor.suppress(closeable, throwable, e);
Reported by PMD.
Line: 219
Closeable closeable = stack.removeFirst();
try {
closeable.close();
} catch (Throwable e) {
if (throwable == null) {
throwable = e;
} else {
suppressor.suppress(closeable, throwable, e);
}
Reported by PMD.
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: 160
* @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: 218
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.
private static final @Nullable Constructor<Thread> bigThreadConstructor =
Reported by PMD.
Line: 172
*/
reference.clear();
if (reference == frqReference) {
/*
* The client no longer has a reference to the FinalizableReferenceQueue. We can stop.
*/
return false;
}
Reported by PMD.
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/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.