The following issues were found
android/guava-tests/test/com/google/common/util/concurrent/SequentialExecutorTest.java
115 issues
Line: 157
@Override
public void run() {
numCalls.incrementAndGet();
throw new RuntimeException("FAKE EXCEPTION!");
}
};
e.execute(runMe);
e.execute(runMe);
Reported by PMD.
Line: 299
try {
barrier.await();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
};
executor.execute(errorTask);
service.execute(barrierTask); // submit directly to the service
Reported by PMD.
Line: 46
*
* @author JJ Furman
*/
public class SequentialExecutorTest extends TestCase {
private static class FakeExecutor implements Executor {
Queue<Runnable> tasks = Queues.newArrayDeque();
@Override
Reported by PMD.
Line: 49
public class SequentialExecutorTest extends TestCase {
private static class FakeExecutor implements Executor {
Queue<Runnable> tasks = Queues.newArrayDeque();
@Override
public void execute(Runnable command) {
tasks.add(command);
}
Reported by PMD.
Line: 62
void runNext() {
assertTrue("expected at least one task to run", hasNext());
tasks.remove().run();
}
void runAll() {
while (hasNext()) {
runNext();
Reported by PMD.
Line: 72
}
}
private FakeExecutor fakePool;
private SequentialExecutor e;
@Override
public void setUp() {
fakePool = new FakeExecutor();
Reported by PMD.
Line: 73
}
private FakeExecutor fakePool;
private SequentialExecutor e;
@Override
public void setUp() {
fakePool = new FakeExecutor();
e = new SequentialExecutor(fakePool);
Reported by PMD.
Line: 75
private FakeExecutor fakePool;
private SequentialExecutor e;
@Override
public void setUp() {
fakePool = new FakeExecutor();
e = new SequentialExecutor(fakePool);
}
Reported by PMD.
Line: 81
e = new SequentialExecutor(fakePool);
}
public void testConstructingWithNullExecutor_fails() {
try {
new SequentialExecutor(null);
fail("Should have failed with NullPointerException.");
} catch (NullPointerException expected) {
}
Reported by PMD.
Line: 84
public void testConstructingWithNullExecutor_fails() {
try {
new SequentialExecutor(null);
fail("Should have failed with NullPointerException.");
} catch (NullPointerException expected) {
}
}
public void testBasics() {
Reported by PMD.
guava-tests/test/com/google/common/graph/AbstractGraphTest.java
115 issues
Line: 50
* TODO(user): Make this class generic (using <N, E>) for all node and edge types.
* TODO(user): Differentiate between directed and undirected edge strings.
*/
public abstract class AbstractGraphTest {
Graph<Integer> graph;
/**
* The same reference as {@link #graph}, except as a mutable graph. This field is null in case
Reported by PMD.
Line: 50
* TODO(user): Make this class generic (using <N, E>) for all node and edge types.
* TODO(user): Differentiate between directed and undirected edge strings.
*/
public abstract class AbstractGraphTest {
Graph<Integer> graph;
/**
* The same reference as {@link #graph}, except as a mutable graph. This field is null in case
Reported by PMD.
Line: 50
* TODO(user): Make this class generic (using <N, E>) for all node and edge types.
* TODO(user): Differentiate between directed and undirected edge strings.
*/
public abstract class AbstractGraphTest {
Graph<Integer> graph;
/**
* The same reference as {@link #graph}, except as a mutable graph. This field is null in case
Reported by PMD.
Line: 52
*/
public abstract class AbstractGraphTest {
Graph<Integer> graph;
/**
* The same reference as {@link #graph}, except as a mutable graph. This field is null in case
* {@link #createGraph()} didn't return a mutable graph.
*/
Reported by PMD.
Line: 58
* The same reference as {@link #graph}, except as a mutable graph. This field is null in case
* {@link #createGraph()} didn't return a mutable graph.
*/
MutableGraph<Integer> graphAsMutableGraph;
static final Integer N1 = 1;
static final Integer N2 = 2;
static final Integer N3 = 3;
static final Integer N4 = 4;
Reported by PMD.
Line: 110
validateGraph(graph);
}
static <N> void validateGraph(Graph<N> graph) {
assertStronglyEquivalent(graph, Graphs.copyOf(graph));
assertStronglyEquivalent(graph, ImmutableGraph.copyOf(graph));
String graphString = graph.toString();
assertThat(graphString).contains("isDirected: " + graph.isDirected());
Reported by PMD.
Line: 110
validateGraph(graph);
}
static <N> void validateGraph(Graph<N> graph) {
assertStronglyEquivalent(graph, Graphs.copyOf(graph));
assertStronglyEquivalent(graph, ImmutableGraph.copyOf(graph));
String graphString = graph.toString();
assertThat(graphString).contains("isDirected: " + graph.isDirected());
Reported by PMD.
Line: 110
validateGraph(graph);
}
static <N> void validateGraph(Graph<N> graph) {
assertStronglyEquivalent(graph, Graphs.copyOf(graph));
assertStronglyEquivalent(graph, ImmutableGraph.copyOf(graph));
String graphString = graph.toString();
assertThat(graphString).contains("isDirected: " + graph.isDirected());
Reported by PMD.
Line: 115
assertStronglyEquivalent(graph, ImmutableGraph.copyOf(graph));
String graphString = graph.toString();
assertThat(graphString).contains("isDirected: " + graph.isDirected());
assertThat(graphString).contains("allowsSelfLoops: " + graph.allowsSelfLoops());
int nodeStart = graphString.indexOf("nodes:");
int edgeStart = graphString.indexOf("edges:");
String nodeString = graphString.substring(nodeStart, edgeStart);
Reported by PMD.
Line: 116
String graphString = graph.toString();
assertThat(graphString).contains("isDirected: " + graph.isDirected());
assertThat(graphString).contains("allowsSelfLoops: " + graph.allowsSelfLoops());
int nodeStart = graphString.indexOf("nodes:");
int edgeStart = graphString.indexOf("edges:");
String nodeString = graphString.substring(nodeStart, edgeStart);
Reported by PMD.
android/guava-tests/test/com/google/common/graph/AbstractGraphTest.java
115 issues
Line: 50
* TODO(user): Make this class generic (using <N, E>) for all node and edge types.
* TODO(user): Differentiate between directed and undirected edge strings.
*/
public abstract class AbstractGraphTest {
Graph<Integer> graph;
/**
* The same reference as {@link #graph}, except as a mutable graph. This field is null in case
Reported by PMD.
Line: 50
* TODO(user): Make this class generic (using <N, E>) for all node and edge types.
* TODO(user): Differentiate between directed and undirected edge strings.
*/
public abstract class AbstractGraphTest {
Graph<Integer> graph;
/**
* The same reference as {@link #graph}, except as a mutable graph. This field is null in case
Reported by PMD.
Line: 50
* TODO(user): Make this class generic (using <N, E>) for all node and edge types.
* TODO(user): Differentiate between directed and undirected edge strings.
*/
public abstract class AbstractGraphTest {
Graph<Integer> graph;
/**
* The same reference as {@link #graph}, except as a mutable graph. This field is null in case
Reported by PMD.
Line: 52
*/
public abstract class AbstractGraphTest {
Graph<Integer> graph;
/**
* The same reference as {@link #graph}, except as a mutable graph. This field is null in case
* {@link #createGraph()} didn't return a mutable graph.
*/
Reported by PMD.
Line: 58
* The same reference as {@link #graph}, except as a mutable graph. This field is null in case
* {@link #createGraph()} didn't return a mutable graph.
*/
MutableGraph<Integer> graphAsMutableGraph;
static final Integer N1 = 1;
static final Integer N2 = 2;
static final Integer N3 = 3;
static final Integer N4 = 4;
Reported by PMD.
Line: 110
validateGraph(graph);
}
static <N> void validateGraph(Graph<N> graph) {
assertStronglyEquivalent(graph, Graphs.copyOf(graph));
assertStronglyEquivalent(graph, ImmutableGraph.copyOf(graph));
String graphString = graph.toString();
assertThat(graphString).contains("isDirected: " + graph.isDirected());
Reported by PMD.
Line: 110
validateGraph(graph);
}
static <N> void validateGraph(Graph<N> graph) {
assertStronglyEquivalent(graph, Graphs.copyOf(graph));
assertStronglyEquivalent(graph, ImmutableGraph.copyOf(graph));
String graphString = graph.toString();
assertThat(graphString).contains("isDirected: " + graph.isDirected());
Reported by PMD.
Line: 110
validateGraph(graph);
}
static <N> void validateGraph(Graph<N> graph) {
assertStronglyEquivalent(graph, Graphs.copyOf(graph));
assertStronglyEquivalent(graph, ImmutableGraph.copyOf(graph));
String graphString = graph.toString();
assertThat(graphString).contains("isDirected: " + graph.isDirected());
Reported by PMD.
Line: 115
assertStronglyEquivalent(graph, ImmutableGraph.copyOf(graph));
String graphString = graph.toString();
assertThat(graphString).contains("isDirected: " + graph.isDirected());
assertThat(graphString).contains("allowsSelfLoops: " + graph.allowsSelfLoops());
int nodeStart = graphString.indexOf("nodes:");
int edgeStart = graphString.indexOf("edges:");
String nodeString = graphString.substring(nodeStart, edgeStart);
Reported by PMD.
Line: 116
String graphString = graph.toString();
assertThat(graphString).contains("isDirected: " + graph.isDirected());
assertThat(graphString).contains("allowsSelfLoops: " + graph.allowsSelfLoops());
int nodeStart = graphString.indexOf("nodes:");
int edgeStart = graphString.indexOf("edges:");
String nodeString = graphString.substring(nodeStart, edgeStart);
Reported by PMD.
android/guava/src/com/google/common/util/concurrent/Monitor.java
114 issues
Line: 1100
/** Caller should check before calling that guard is not satisfied. */
@GuardedBy("lock")
private boolean awaitNanos(Guard guard, long nanos, boolean signalBeforeWaiting)
throws InterruptedException {
boolean firstTime = true;
try {
do {
if (nanos <= 0L) {
Reported by PMD.
Line: 204
@GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
@ElementTypesAreNonnullByDefault
public final class Monitor {
// TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
// TODO(user): "Port" jsr166 tests for ReentrantLock.
//
// TODO(user): Change API to make it impossible to use a Guard with the "wrong" monitor,
// by making the monitor implicit, and to eliminate other sources of IMSE.
Reported by PMD.
Line: 204
@GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
@ElementTypesAreNonnullByDefault
public final class Monitor {
// TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
// TODO(user): "Port" jsr166 tests for ReentrantLock.
//
// TODO(user): Change API to make it impossible to use a Guard with the "wrong" monitor,
// by making the monitor implicit, and to eliminate other sources of IMSE.
Reported by PMD.
Line: 204
@GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
@ElementTypesAreNonnullByDefault
public final class Monitor {
// TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
// TODO(user): "Port" jsr166 tests for ReentrantLock.
//
// TODO(user): Change API to make it impossible to use a Guard with the "wrong" monitor,
// by making the monitor implicit, and to eliminate other sources of IMSE.
Reported by PMD.
Line: 204
@GwtIncompatible
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
@ElementTypesAreNonnullByDefault
public final class Monitor {
// TODO(user): Use raw LockSupport or AbstractQueuedSynchronizer instead of ReentrantLock.
// TODO(user): "Port" jsr166 tests for ReentrantLock.
//
// TODO(user): Change API to make it impossible to use a Guard with the "wrong" monitor,
// by making the monitor implicit, and to eliminate other sources of IMSE.
Reported by PMD.
Line: 307
@Beta
public abstract static class Guard {
@Weak final Monitor monitor;
final Condition condition;
@GuardedBy("monitor.lock")
int waiterCount = 0;
Reported by PMD.
Line: 308
public abstract static class Guard {
@Weak final Monitor monitor;
final Condition condition;
@GuardedBy("monitor.lock")
int waiterCount = 0;
/** The next active guard */
Reported by PMD.
Line: 311
final Condition condition;
@GuardedBy("monitor.lock")
int waiterCount = 0;
/** The next active guard */
@GuardedBy("monitor.lock")
@CheckForNull
Guard next;
Reported by PMD.
Line: 311
final Condition condition;
@GuardedBy("monitor.lock")
int waiterCount = 0;
/** The next active guard */
@GuardedBy("monitor.lock")
@CheckForNull
Guard next;
Reported by PMD.
Line: 316
/** The next active guard */
@GuardedBy("monitor.lock")
@CheckForNull
Guard next;
protected Guard(Monitor monitor) {
this.monitor = checkNotNull(monitor, "monitor");
this.condition = monitor.lock.newCondition();
}
Reported by PMD.
guava-tests/test/com/google/common/base/ConverterTest.java
113 issues
Line: 33
/** Unit tests for {@link Converter}. */
@GwtCompatible
public class ConverterTest extends TestCase {
private static final Converter<String, Long> STR_TO_LONG =
new Converter<String, Long>() {
@Override
protected Long doForward(String object) {
Reported by PMD.
Line: 59
private static final ImmutableList<String> STRINGS = ImmutableList.of("123", "456");
private static final ImmutableList<Long> LONGS = ImmutableList.of(123L, 456L);
public void testConverter() {
assertEquals(LONG_VAL, STR_TO_LONG.convert(STR_VAL));
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
Reported by PMD.
Line: 59
private static final ImmutableList<String> STRINGS = ImmutableList.of("123", "456");
private static final ImmutableList<Long> LONGS = ImmutableList.of(123L, 456L);
public void testConverter() {
assertEquals(LONG_VAL, STR_TO_LONG.convert(STR_VAL));
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
Reported by PMD.
Line: 60
private static final ImmutableList<Long> LONGS = ImmutableList.of(123L, 456L);
public void testConverter() {
assertEquals(LONG_VAL, STR_TO_LONG.convert(STR_VAL));
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
Reported by PMD.
Line: 61
public void testConverter() {
assertEquals(LONG_VAL, STR_TO_LONG.convert(STR_VAL));
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
Reported by PMD.
Line: 61
public void testConverter() {
assertEquals(LONG_VAL, STR_TO_LONG.convert(STR_VAL));
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
Reported by PMD.
Line: 64
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
public void testConvertAllIsView() {
List<String> mutableList = Lists.newArrayList("789", "123");
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(mutableList);
Reported by PMD.
Line: 67
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
public void testConvertAllIsView() {
List<String> mutableList = Lists.newArrayList("789", "123");
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(mutableList);
assertEquals(ImmutableList.of(789L, 123L), ImmutableList.copyOf(convertedValues));
Iterator<Long> iterator = convertedValues.iterator();
Reported by PMD.
Line: 67
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
public void testConvertAllIsView() {
List<String> mutableList = Lists.newArrayList("789", "123");
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(mutableList);
assertEquals(ImmutableList.of(789L, 123L), ImmutableList.copyOf(convertedValues));
Iterator<Long> iterator = convertedValues.iterator();
Reported by PMD.
Line: 70
public void testConvertAllIsView() {
List<String> mutableList = Lists.newArrayList("789", "123");
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(mutableList);
assertEquals(ImmutableList.of(789L, 123L), ImmutableList.copyOf(convertedValues));
Iterator<Long> iterator = convertedValues.iterator();
iterator.next();
iterator.remove();
assertEquals(ImmutableList.of("123"), mutableList);
Reported by PMD.
guava/src/com/google/common/util/concurrent/AbstractFuture.java
113 issues
Line: 1346
}
});
} catch (PrivilegedActionException e) {
throw new RuntimeException("Could not initialize intrinsics", e.getCause());
}
}
try {
Class<?> abstractFuture = AbstractFuture.class;
WAITERS_OFFSET = unsafe.objectFieldOffset(abstractFuture.getDeclaredField("waiters"));
Reported by PMD.
Line: 1359
UNSAFE = unsafe;
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
@Override
void putThread(Waiter waiter, Thread newValue) {
Reported by PMD.
Line: 271
}
curr = succ;
}
break;
}
}
/** Listeners also form a stack through the {@link #listeners} field. */
private static final class Listener {
Reported by PMD.
Line: 1041
executeListener(task, requireNonNull(curr.executor));
}
}
break;
}
}
/**
* Callback method that is called exactly once after the future is completed.
Reported by PMD.
Line: 1282
// Log it and keep going -- bad runnable and/or executor. Don't punish the other runnables if
// we're given a bad one. We only catch RuntimeException because we want Errors to propagate
// up.
log.log(
Level.SEVERE,
"RuntimeException while executing runnable " + runnable + " with executor " + executor,
e);
}
}
Reported by PMD.
Line: 15
* the License.
*/
package com.google.common.util.concurrent;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
import static com.google.common.util.concurrent.NullnessCasts.uncheckedNull;
import static java.lang.Integer.toHexString;
Reported by PMD.
Line: 77
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
@ElementTypesAreNonnullByDefault
public abstract class AbstractFuture<V extends @Nullable Object> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
private static final boolean GENERATE_CANCELLATION_CAUSES;
Reported by PMD.
Line: 77
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
@ElementTypesAreNonnullByDefault
public abstract class AbstractFuture<V extends @Nullable Object> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
private static final boolean GENERATE_CANCELLATION_CAUSES;
Reported by PMD.
Line: 77
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
@ElementTypesAreNonnullByDefault
public abstract class AbstractFuture<V extends @Nullable Object> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
private static final boolean GENERATE_CANCELLATION_CAUSES;
Reported by PMD.
Line: 77
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
@ElementTypesAreNonnullByDefault
public abstract class AbstractFuture<V extends @Nullable Object> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
private static final boolean GENERATE_CANCELLATION_CAUSES;
Reported by PMD.
android/guava-tests/test/com/google/common/base/ConverterTest.java
113 issues
Line: 33
/** Unit tests for {@link Converter}. */
@GwtCompatible
public class ConverterTest extends TestCase {
private static final Converter<String, Long> STR_TO_LONG =
new Converter<String, Long>() {
@Override
protected Long doForward(String object) {
Reported by PMD.
Line: 59
private static final ImmutableList<String> STRINGS = ImmutableList.of("123", "456");
private static final ImmutableList<Long> LONGS = ImmutableList.of(123L, 456L);
public void testConverter() {
assertEquals(LONG_VAL, STR_TO_LONG.convert(STR_VAL));
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
Reported by PMD.
Line: 59
private static final ImmutableList<String> STRINGS = ImmutableList.of("123", "456");
private static final ImmutableList<Long> LONGS = ImmutableList.of(123L, 456L);
public void testConverter() {
assertEquals(LONG_VAL, STR_TO_LONG.convert(STR_VAL));
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
Reported by PMD.
Line: 60
private static final ImmutableList<Long> LONGS = ImmutableList.of(123L, 456L);
public void testConverter() {
assertEquals(LONG_VAL, STR_TO_LONG.convert(STR_VAL));
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
Reported by PMD.
Line: 61
public void testConverter() {
assertEquals(LONG_VAL, STR_TO_LONG.convert(STR_VAL));
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
Reported by PMD.
Line: 61
public void testConverter() {
assertEquals(LONG_VAL, STR_TO_LONG.convert(STR_VAL));
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
Reported by PMD.
Line: 64
assertEquals(STR_VAL, STR_TO_LONG.reverse().convert(LONG_VAL));
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(STRINGS);
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
public void testConvertAllIsView() {
List<String> mutableList = Lists.newArrayList("789", "123");
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(mutableList);
Reported by PMD.
Line: 67
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
public void testConvertAllIsView() {
List<String> mutableList = Lists.newArrayList("789", "123");
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(mutableList);
assertEquals(ImmutableList.of(789L, 123L), ImmutableList.copyOf(convertedValues));
Iterator<Long> iterator = convertedValues.iterator();
Reported by PMD.
Line: 67
assertEquals(LONGS, ImmutableList.copyOf(convertedValues));
}
public void testConvertAllIsView() {
List<String> mutableList = Lists.newArrayList("789", "123");
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(mutableList);
assertEquals(ImmutableList.of(789L, 123L), ImmutableList.copyOf(convertedValues));
Iterator<Long> iterator = convertedValues.iterator();
Reported by PMD.
Line: 70
public void testConvertAllIsView() {
List<String> mutableList = Lists.newArrayList("789", "123");
Iterable<Long> convertedValues = STR_TO_LONG.convertAll(mutableList);
assertEquals(ImmutableList.of(789L, 123L), ImmutableList.copyOf(convertedValues));
Iterator<Long> iterator = convertedValues.iterator();
iterator.next();
iterator.remove();
assertEquals(ImmutableList.of("123"), mutableList);
Reported by PMD.
android/guava/src/com/google/common/util/concurrent/AbstractFuture.java
113 issues
Line: 1346
}
});
} catch (PrivilegedActionException e) {
throw new RuntimeException("Could not initialize intrinsics", e.getCause());
}
}
try {
Class<?> abstractFuture = AbstractFuture.class;
WAITERS_OFFSET = unsafe.objectFieldOffset(abstractFuture.getDeclaredField("waiters"));
Reported by PMD.
Line: 1359
UNSAFE = unsafe;
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
@Override
void putThread(Waiter waiter, Thread newValue) {
Reported by PMD.
Line: 271
}
curr = succ;
}
break;
}
}
/** Listeners also form a stack through the {@link #listeners} field. */
private static final class Listener {
Reported by PMD.
Line: 1041
executeListener(task, requireNonNull(curr.executor));
}
}
break;
}
}
/**
* Callback method that is called exactly once after the future is completed.
Reported by PMD.
Line: 1282
// Log it and keep going -- bad runnable and/or executor. Don't punish the other runnables if
// we're given a bad one. We only catch RuntimeException because we want Errors to propagate
// up.
log.log(
Level.SEVERE,
"RuntimeException while executing runnable " + runnable + " with executor " + executor,
e);
}
}
Reported by PMD.
Line: 15
* the License.
*/
package com.google.common.util.concurrent;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
import static com.google.common.util.concurrent.NullnessCasts.uncheckedNull;
import static java.lang.Integer.toHexString;
Reported by PMD.
Line: 77
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
@ElementTypesAreNonnullByDefault
public abstract class AbstractFuture<V extends @Nullable Object> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
private static final boolean GENERATE_CANCELLATION_CAUSES;
Reported by PMD.
Line: 77
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
@ElementTypesAreNonnullByDefault
public abstract class AbstractFuture<V extends @Nullable Object> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
private static final boolean GENERATE_CANCELLATION_CAUSES;
Reported by PMD.
Line: 77
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
@ElementTypesAreNonnullByDefault
public abstract class AbstractFuture<V extends @Nullable Object> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
private static final boolean GENERATE_CANCELLATION_CAUSES;
Reported by PMD.
Line: 77
@GwtCompatible(emulated = true)
@ReflectionSupport(value = ReflectionSupport.Level.FULL)
@ElementTypesAreNonnullByDefault
public abstract class AbstractFuture<V extends @Nullable Object> extends InternalFutureFailureAccess
implements ListenableFuture<V> {
// NOTE: Whenever both tests are cheap and functional, it's faster to use &, | instead of &&, ||
private static final boolean GENERATE_CANCELLATION_CAUSES;
Reported by PMD.
guava-tests/test/com/google/common/primitives/UnsignedLongTest.java
112 issues
Line: 32
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class UnsignedLongTest extends TestCase {
private static final ImmutableSet<Long> TEST_LONGS;
private static final ImmutableSet<BigInteger> TEST_BIG_INTEGERS;
static {
ImmutableSet.Builder<Long> testLongsBuilder = ImmutableSet.builder();
Reported by PMD.
Line: 70
TEST_BIG_INTEGERS = testBigIntegersBuilder.build();
}
public void testAsUnsignedAndLongValueAreInverses() {
for (long value : TEST_LONGS) {
assertEquals(
UnsignedLongs.toString(value), value, UnsignedLong.fromLongBits(value).longValue());
}
}
Reported by PMD.
Line: 73
public void testAsUnsignedAndLongValueAreInverses() {
for (long value : TEST_LONGS) {
assertEquals(
UnsignedLongs.toString(value), value, UnsignedLong.fromLongBits(value).longValue());
}
}
public void testAsUnsignedBigIntegerValue() {
for (long value : TEST_LONGS) {
Reported by PMD.
Line: 77
}
}
public void testAsUnsignedBigIntegerValue() {
for (long value : TEST_LONGS) {
BigInteger expected =
(value >= 0)
? BigInteger.valueOf(value)
: BigInteger.valueOf(value).add(BigInteger.ZERO.setBit(64));
Reported by PMD.
Line: 82
BigInteger expected =
(value >= 0)
? BigInteger.valueOf(value)
: BigInteger.valueOf(value).add(BigInteger.ZERO.setBit(64));
assertEquals(
UnsignedLongs.toString(value),
expected,
UnsignedLong.fromLongBits(value).bigIntegerValue());
}
Reported by PMD.
Line: 82
BigInteger expected =
(value >= 0)
? BigInteger.valueOf(value)
: BigInteger.valueOf(value).add(BigInteger.ZERO.setBit(64));
assertEquals(
UnsignedLongs.toString(value),
expected,
UnsignedLong.fromLongBits(value).bigIntegerValue());
}
Reported by PMD.
Line: 86
assertEquals(
UnsignedLongs.toString(value),
expected,
UnsignedLong.fromLongBits(value).bigIntegerValue());
}
}
public void testValueOfLong() {
for (long value : TEST_LONGS) {
Reported by PMD.
Line: 90
}
}
public void testValueOfLong() {
for (long value : TEST_LONGS) {
boolean expectSuccess = value >= 0;
try {
assertEquals(value, UnsignedLong.valueOf(value).longValue());
assertTrue(expectSuccess);
Reported by PMD.
Line: 90
}
}
public void testValueOfLong() {
for (long value : TEST_LONGS) {
boolean expectSuccess = value >= 0;
try {
assertEquals(value, UnsignedLong.valueOf(value).longValue());
assertTrue(expectSuccess);
Reported by PMD.
Line: 94
for (long value : TEST_LONGS) {
boolean expectSuccess = value >= 0;
try {
assertEquals(value, UnsignedLong.valueOf(value).longValue());
assertTrue(expectSuccess);
} catch (IllegalArgumentException e) {
assertFalse(expectSuccess);
}
}
Reported by PMD.
android/guava-tests/test/com/google/common/primitives/UnsignedLongTest.java
112 issues
Line: 32
* @author Louis Wasserman
*/
@GwtCompatible(emulated = true)
public class UnsignedLongTest extends TestCase {
private static final ImmutableSet<Long> TEST_LONGS;
private static final ImmutableSet<BigInteger> TEST_BIG_INTEGERS;
static {
ImmutableSet.Builder<Long> testLongsBuilder = ImmutableSet.builder();
Reported by PMD.
Line: 70
TEST_BIG_INTEGERS = testBigIntegersBuilder.build();
}
public void testAsUnsignedAndLongValueAreInverses() {
for (long value : TEST_LONGS) {
assertEquals(
UnsignedLongs.toString(value), value, UnsignedLong.fromLongBits(value).longValue());
}
}
Reported by PMD.
Line: 73
public void testAsUnsignedAndLongValueAreInverses() {
for (long value : TEST_LONGS) {
assertEquals(
UnsignedLongs.toString(value), value, UnsignedLong.fromLongBits(value).longValue());
}
}
public void testAsUnsignedBigIntegerValue() {
for (long value : TEST_LONGS) {
Reported by PMD.
Line: 77
}
}
public void testAsUnsignedBigIntegerValue() {
for (long value : TEST_LONGS) {
BigInteger expected =
(value >= 0)
? BigInteger.valueOf(value)
: BigInteger.valueOf(value).add(BigInteger.ZERO.setBit(64));
Reported by PMD.
Line: 82
BigInteger expected =
(value >= 0)
? BigInteger.valueOf(value)
: BigInteger.valueOf(value).add(BigInteger.ZERO.setBit(64));
assertEquals(
UnsignedLongs.toString(value),
expected,
UnsignedLong.fromLongBits(value).bigIntegerValue());
}
Reported by PMD.
Line: 82
BigInteger expected =
(value >= 0)
? BigInteger.valueOf(value)
: BigInteger.valueOf(value).add(BigInteger.ZERO.setBit(64));
assertEquals(
UnsignedLongs.toString(value),
expected,
UnsignedLong.fromLongBits(value).bigIntegerValue());
}
Reported by PMD.
Line: 86
assertEquals(
UnsignedLongs.toString(value),
expected,
UnsignedLong.fromLongBits(value).bigIntegerValue());
}
}
public void testValueOfLong() {
for (long value : TEST_LONGS) {
Reported by PMD.
Line: 90
}
}
public void testValueOfLong() {
for (long value : TEST_LONGS) {
boolean expectSuccess = value >= 0;
try {
assertEquals(value, UnsignedLong.valueOf(value).longValue());
assertTrue(expectSuccess);
Reported by PMD.
Line: 90
}
}
public void testValueOfLong() {
for (long value : TEST_LONGS) {
boolean expectSuccess = value >= 0;
try {
assertEquals(value, UnsignedLong.valueOf(value).longValue());
assertTrue(expectSuccess);
Reported by PMD.
Line: 94
for (long value : TEST_LONGS) {
boolean expectSuccess = value >= 0;
try {
assertEquals(value, UnsignedLong.valueOf(value).longValue());
assertTrue(expectSuccess);
} catch (IllegalArgumentException e) {
assertFalse(expectSuccess);
}
}
Reported by PMD.