The following issues were found
guava-tests/test/com/google/common/base/AsciiTest.java
80 issues
Line: 134
assertTrue(Ascii.equalsIgnoreCase(LOWER, UPPER));
assertTrue(Ascii.equalsIgnoreCase(UPPER, LOWER));
// Create new strings here to avoid early-out logic.
assertTrue(Ascii.equalsIgnoreCase(new String(IGNORED), new String(IGNORED)));
// Compare to: "\u00c1".equalsIgnoreCase("\u00e1") == true
assertFalse(Ascii.equalsIgnoreCase("\u00c1", "\u00e1"));
// Test chars just outside the alphabetic range ('A'-1 vs 'a'-1, 'Z'+1 vs 'z'+1)
assertFalse(Ascii.equalsIgnoreCase("@", "`"));
assertFalse(Ascii.equalsIgnoreCase("[", "{"));
Reported by PMD.
Line: 134
assertTrue(Ascii.equalsIgnoreCase(LOWER, UPPER));
assertTrue(Ascii.equalsIgnoreCase(UPPER, LOWER));
// Create new strings here to avoid early-out logic.
assertTrue(Ascii.equalsIgnoreCase(new String(IGNORED), new String(IGNORED)));
// Compare to: "\u00c1".equalsIgnoreCase("\u00e1") == true
assertFalse(Ascii.equalsIgnoreCase("\u00c1", "\u00e1"));
// Test chars just outside the alphabetic range ('A'-1 vs 'a'-1, 'Z'+1 vs 'z'+1)
assertFalse(Ascii.equalsIgnoreCase("@", "`"));
assertFalse(Ascii.equalsIgnoreCase("[", "{"));
Reported by PMD.
Line: 40
private static final String LOWER = "abcdefghijklmnopqrstuvwxyz";
private static final String UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public void testToLowerCase() {
assertEquals(LOWER, Ascii.toLowerCase(UPPER));
assertSame(LOWER, Ascii.toLowerCase(LOWER));
assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
}
Reported by PMD.
Line: 40
private static final String LOWER = "abcdefghijklmnopqrstuvwxyz";
private static final String UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public void testToLowerCase() {
assertEquals(LOWER, Ascii.toLowerCase(UPPER));
assertSame(LOWER, Ascii.toLowerCase(LOWER));
assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
}
Reported by PMD.
Line: 41
private static final String UPPER = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
public void testToLowerCase() {
assertEquals(LOWER, Ascii.toLowerCase(UPPER));
assertSame(LOWER, Ascii.toLowerCase(LOWER));
assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
}
Reported by PMD.
Line: 42
public void testToLowerCase() {
assertEquals(LOWER, Ascii.toLowerCase(UPPER));
assertSame(LOWER, Ascii.toLowerCase(LOWER));
assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
}
public void testToUpperCase() {
Reported by PMD.
Line: 43
public void testToLowerCase() {
assertEquals(LOWER, Ascii.toLowerCase(UPPER));
assertSame(LOWER, Ascii.toLowerCase(LOWER));
assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
}
public void testToUpperCase() {
assertEquals(UPPER, Ascii.toUpperCase(LOWER));
Reported by PMD.
Line: 44
assertEquals(LOWER, Ascii.toLowerCase(UPPER));
assertSame(LOWER, Ascii.toLowerCase(LOWER));
assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
}
public void testToUpperCase() {
assertEquals(UPPER, Ascii.toUpperCase(LOWER));
assertSame(UPPER, Ascii.toUpperCase(UPPER));
Reported by PMD.
Line: 44
assertEquals(LOWER, Ascii.toLowerCase(UPPER));
assertSame(LOWER, Ascii.toLowerCase(LOWER));
assertEquals(IGNORED, Ascii.toLowerCase(IGNORED));
assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
}
public void testToUpperCase() {
assertEquals(UPPER, Ascii.toUpperCase(LOWER));
assertSame(UPPER, Ascii.toUpperCase(UPPER));
Reported by PMD.
Line: 47
assertEquals("foobar", Ascii.toLowerCase("fOobaR"));
}
public void testToUpperCase() {
assertEquals(UPPER, Ascii.toUpperCase(LOWER));
assertSame(UPPER, Ascii.toUpperCase(UPPER));
assertEquals(IGNORED, Ascii.toUpperCase(IGNORED));
assertEquals("FOOBAR", Ascii.toUpperCase("FoOBAr"));
}
Reported by PMD.
guava/src/com/google/common/graph/Graphs.java
79 issues
Line: 17
* limitations under the License.
*/
package com.google.common.graph;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.graph.GraphConstants.NODE_NOT_IN_GRAPH;
import static java.util.Objects.requireNonNull;
Reported by PMD.
Line: 48
*/
@Beta
@ElementTypesAreNonnullByDefault
public final class Graphs {
private Graphs() {}
// Graph query methods
Reported by PMD.
Line: 48
*/
@Beta
@ElementTypesAreNonnullByDefault
public final class Graphs {
private Graphs() {}
// Graph query methods
Reported by PMD.
Line: 62
* <p>This method will detect any non-empty cycle, including self-loops (a cycle of length 1).
*/
public static <N> boolean hasCycle(Graph<N> graph) {
int numEdges = graph.edges().size();
if (numEdges == 0) {
return false; // An edge-free graph is acyclic by definition.
}
if (!graph.isDirected() && numEdges >= graph.nodes().size()) {
return true; // Optimization for the undirected case: at least one cycle must exist.
Reported by PMD.
Line: 66
if (numEdges == 0) {
return false; // An edge-free graph is acyclic by definition.
}
if (!graph.isDirected() && numEdges >= graph.nodes().size()) {
return true; // Optimization for the undirected case: at least one cycle must exist.
}
Map<Object, NodeVisitState> visitedNodes =
Maps.newHashMapWithExpectedSize(graph.nodes().size());
Reported by PMD.
Line: 71
}
Map<Object, NodeVisitState> visitedNodes =
Maps.newHashMapWithExpectedSize(graph.nodes().size());
for (N node : graph.nodes()) {
if (subgraphHasCycle(graph, visitedNodes, node, null)) {
return true;
}
}
Reported by PMD.
Line: 92
// However, in an undirected graph, any parallel edge induces a cycle in the graph.
if (!network.isDirected()
&& network.allowsParallelEdges()
&& network.edges().size() > network.asGraph().edges().size()) {
return true;
}
return hasCycle(network.asGraph());
}
Reported by PMD.
Line: 92
// However, in an undirected graph, any parallel edge induces a cycle in the graph.
if (!network.isDirected()
&& network.allowsParallelEdges()
&& network.edges().size() > network.asGraph().edges().size()) {
return true;
}
return hasCycle(network.asGraph());
}
Reported by PMD.
Line: 92
// However, in an undirected graph, any parallel edge induces a cycle in the graph.
if (!network.isDirected()
&& network.allowsParallelEdges()
&& network.edges().size() > network.asGraph().edges().size()) {
return true;
}
return hasCycle(network.asGraph());
}
Reported by PMD.
Line: 135
*/
private static boolean canTraverseWithoutReusingEdge(
Graph<?> graph, Object nextNode, @CheckForNull Object previousNode) {
if (graph.isDirected() || !Objects.equal(previousNode, nextNode)) {
return true;
}
// This falls into the undirected A->B->A case. The Graph interface does not support parallel
// edges, so this traversal would require reusing the undirected AB edge.
return false;
Reported by PMD.
guava-tests/test/com/google/common/base/StopwatchTest.java
79 issues
Line: 33
* @author Kevin Bourrillion
*/
@GwtCompatible
public class StopwatchTest extends TestCase {
private final FakeTicker ticker = new FakeTicker();
private final Stopwatch stopwatch = new Stopwatch(ticker);
public void testCreateStarted() {
Reported by PMD.
Line: 35
@GwtCompatible
public class StopwatchTest extends TestCase {
private final FakeTicker ticker = new FakeTicker();
private final Stopwatch stopwatch = new Stopwatch(ticker);
public void testCreateStarted() {
Stopwatch startedStopwatch = Stopwatch.createStarted();
assertTrue(startedStopwatch.isRunning());
Reported by PMD.
Line: 36
public class StopwatchTest extends TestCase {
private final FakeTicker ticker = new FakeTicker();
private final Stopwatch stopwatch = new Stopwatch(ticker);
public void testCreateStarted() {
Stopwatch startedStopwatch = Stopwatch.createStarted();
assertTrue(startedStopwatch.isRunning());
}
Reported by PMD.
Line: 38
private final FakeTicker ticker = new FakeTicker();
private final Stopwatch stopwatch = new Stopwatch(ticker);
public void testCreateStarted() {
Stopwatch startedStopwatch = Stopwatch.createStarted();
assertTrue(startedStopwatch.isRunning());
}
public void testCreateUnstarted() {
Reported by PMD.
Line: 40
public void testCreateStarted() {
Stopwatch startedStopwatch = Stopwatch.createStarted();
assertTrue(startedStopwatch.isRunning());
}
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
Reported by PMD.
Line: 40
public void testCreateStarted() {
Stopwatch startedStopwatch = Stopwatch.createStarted();
assertTrue(startedStopwatch.isRunning());
}
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
Reported by PMD.
Line: 43
assertTrue(startedStopwatch.isRunning());
}
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
}
Reported by PMD.
Line: 43
assertTrue(startedStopwatch.isRunning());
}
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
}
Reported by PMD.
Line: 45
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
}
public void testInitialState() {
assertFalse(stopwatch.isRunning());
Reported by PMD.
Line: 45
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
}
public void testInitialState() {
assertFalse(stopwatch.isRunning());
Reported by PMD.
guava-tests/test/com/google/common/reflect/TypeResolverTest.java
79 issues
Line: 31
* @author Ben Yu
*/
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeResolverTest extends TestCase {
public void testWhere_noMapping() {
Type t = aTypeVariable();
assertEquals(t, new TypeResolver().resolveType(t));
}
Reported by PMD.
Line: 33
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeResolverTest extends TestCase {
public void testWhere_noMapping() {
Type t = aTypeVariable();
assertEquals(t, new TypeResolver().resolveType(t));
}
public void testWhere_typeVariableMapping() {
Reported by PMD.
Line: 35
public void testWhere_noMapping() {
Type t = aTypeVariable();
assertEquals(t, new TypeResolver().resolveType(t));
}
public void testWhere_typeVariableMapping() {
Type t = aTypeVariable();
assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
Reported by PMD.
Line: 38
assertEquals(t, new TypeResolver().resolveType(t));
}
public void testWhere_typeVariableMapping() {
Type t = aTypeVariable();
assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
}
public <T> void testWhere_indirectMapping() {
Reported by PMD.
Line: 40
public void testWhere_typeVariableMapping() {
Type t = aTypeVariable();
assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
}
public <T> void testWhere_indirectMapping() {
Type t1 = new TypeCapture<T>() {}.capture();
Type t2 = aTypeVariable();
Reported by PMD.
Line: 43
assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
}
public <T> void testWhere_indirectMapping() {
Type t1 = new TypeCapture<T>() {}.capture();
Type t2 = aTypeVariable();
assertEquals(
String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
}
Reported by PMD.
Line: 46
public <T> void testWhere_indirectMapping() {
Type t1 = new TypeCapture<T>() {}.capture();
Type t2 = aTypeVariable();
assertEquals(
String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
}
public void testWhere_typeVariableSelfMapping() {
TypeResolver resolver = new TypeResolver();
Reported by PMD.
Line: 50
String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
}
public void testWhere_typeVariableSelfMapping() {
TypeResolver resolver = new TypeResolver();
Type t = aTypeVariable();
assertEquals(t, resolver.where(t, t).resolveType(t));
}
Reported by PMD.
Line: 53
public void testWhere_typeVariableSelfMapping() {
TypeResolver resolver = new TypeResolver();
Type t = aTypeVariable();
assertEquals(t, resolver.where(t, t).resolveType(t));
}
public <T> void testWhere_parameterizedSelfMapping() {
TypeResolver resolver = new TypeResolver();
Type t = new TypeCapture<List<T>>() {}.capture();
Reported by PMD.
Line: 53
public void testWhere_typeVariableSelfMapping() {
TypeResolver resolver = new TypeResolver();
Type t = aTypeVariable();
assertEquals(t, resolver.where(t, t).resolveType(t));
}
public <T> void testWhere_parameterizedSelfMapping() {
TypeResolver resolver = new TypeResolver();
Type t = new TypeCapture<List<T>>() {}.capture();
Reported by PMD.
android/guava-tests/test/com/google/common/base/StopwatchTest.java
79 issues
Line: 33
* @author Kevin Bourrillion
*/
@GwtCompatible
public class StopwatchTest extends TestCase {
private final FakeTicker ticker = new FakeTicker();
private final Stopwatch stopwatch = new Stopwatch(ticker);
public void testCreateStarted() {
Reported by PMD.
Line: 35
@GwtCompatible
public class StopwatchTest extends TestCase {
private final FakeTicker ticker = new FakeTicker();
private final Stopwatch stopwatch = new Stopwatch(ticker);
public void testCreateStarted() {
Stopwatch startedStopwatch = Stopwatch.createStarted();
assertTrue(startedStopwatch.isRunning());
Reported by PMD.
Line: 36
public class StopwatchTest extends TestCase {
private final FakeTicker ticker = new FakeTicker();
private final Stopwatch stopwatch = new Stopwatch(ticker);
public void testCreateStarted() {
Stopwatch startedStopwatch = Stopwatch.createStarted();
assertTrue(startedStopwatch.isRunning());
}
Reported by PMD.
Line: 38
private final FakeTicker ticker = new FakeTicker();
private final Stopwatch stopwatch = new Stopwatch(ticker);
public void testCreateStarted() {
Stopwatch startedStopwatch = Stopwatch.createStarted();
assertTrue(startedStopwatch.isRunning());
}
public void testCreateUnstarted() {
Reported by PMD.
Line: 40
public void testCreateStarted() {
Stopwatch startedStopwatch = Stopwatch.createStarted();
assertTrue(startedStopwatch.isRunning());
}
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
Reported by PMD.
Line: 40
public void testCreateStarted() {
Stopwatch startedStopwatch = Stopwatch.createStarted();
assertTrue(startedStopwatch.isRunning());
}
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
Reported by PMD.
Line: 43
assertTrue(startedStopwatch.isRunning());
}
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
}
Reported by PMD.
Line: 43
assertTrue(startedStopwatch.isRunning());
}
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
}
Reported by PMD.
Line: 45
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
}
public void testInitialState() {
assertFalse(stopwatch.isRunning());
Reported by PMD.
Line: 45
public void testCreateUnstarted() {
Stopwatch unstartedStopwatch = Stopwatch.createUnstarted();
assertFalse(unstartedStopwatch.isRunning());
assertEquals(0, unstartedStopwatch.elapsed(NANOSECONDS));
}
public void testInitialState() {
assertFalse(stopwatch.isRunning());
Reported by PMD.
android/guava-tests/test/com/google/common/reflect/TypeResolverTest.java
79 issues
Line: 31
* @author Ben Yu
*/
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeResolverTest extends TestCase {
public void testWhere_noMapping() {
Type t = aTypeVariable();
assertEquals(t, new TypeResolver().resolveType(t));
}
Reported by PMD.
Line: 33
@AndroidIncompatible // lots of failures, possibly some related to bad equals() implementations?
public class TypeResolverTest extends TestCase {
public void testWhere_noMapping() {
Type t = aTypeVariable();
assertEquals(t, new TypeResolver().resolveType(t));
}
public void testWhere_typeVariableMapping() {
Reported by PMD.
Line: 35
public void testWhere_noMapping() {
Type t = aTypeVariable();
assertEquals(t, new TypeResolver().resolveType(t));
}
public void testWhere_typeVariableMapping() {
Type t = aTypeVariable();
assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
Reported by PMD.
Line: 38
assertEquals(t, new TypeResolver().resolveType(t));
}
public void testWhere_typeVariableMapping() {
Type t = aTypeVariable();
assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
}
public <T> void testWhere_indirectMapping() {
Reported by PMD.
Line: 40
public void testWhere_typeVariableMapping() {
Type t = aTypeVariable();
assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
}
public <T> void testWhere_indirectMapping() {
Type t1 = new TypeCapture<T>() {}.capture();
Type t2 = aTypeVariable();
Reported by PMD.
Line: 43
assertEquals(String.class, new TypeResolver().where(t, String.class).resolveType(t));
}
public <T> void testWhere_indirectMapping() {
Type t1 = new TypeCapture<T>() {}.capture();
Type t2 = aTypeVariable();
assertEquals(
String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
}
Reported by PMD.
Line: 46
public <T> void testWhere_indirectMapping() {
Type t1 = new TypeCapture<T>() {}.capture();
Type t2 = aTypeVariable();
assertEquals(
String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
}
public void testWhere_typeVariableSelfMapping() {
TypeResolver resolver = new TypeResolver();
Reported by PMD.
Line: 50
String.class, new TypeResolver().where(t1, t2).where(t2, String.class).resolveType(t1));
}
public void testWhere_typeVariableSelfMapping() {
TypeResolver resolver = new TypeResolver();
Type t = aTypeVariable();
assertEquals(t, resolver.where(t, t).resolveType(t));
}
Reported by PMD.
Line: 53
public void testWhere_typeVariableSelfMapping() {
TypeResolver resolver = new TypeResolver();
Type t = aTypeVariable();
assertEquals(t, resolver.where(t, t).resolveType(t));
}
public <T> void testWhere_parameterizedSelfMapping() {
TypeResolver resolver = new TypeResolver();
Type t = new TypeCapture<List<T>>() {}.capture();
Reported by PMD.
Line: 53
public void testWhere_typeVariableSelfMapping() {
TypeResolver resolver = new TypeResolver();
Type t = aTypeVariable();
assertEquals(t, resolver.where(t, t).resolveType(t));
}
public <T> void testWhere_parameterizedSelfMapping() {
TypeResolver resolver = new TypeResolver();
Type t = new TypeCapture<List<T>>() {}.capture();
Reported by PMD.
guava-tests/test/com/google/common/collect/SynchronizedDequeTest.java
78 issues
Line: 41
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
public final Object mutex = new Integer(1); // something Serializable
@Override
public boolean offer(E o) {
assertTrue(Thread.holdsLock(mutex));
return delegate.offer(o);
Reported by PMD.
Line: 35
protected Deque<String> create() {
TestDeque<String> inner = new TestDeque<>();
Deque<String> outer = Synchronized.deque(inner, inner.mutex);
outer.add("foo"); // necessary because we try to remove elements later on
return outer;
}
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
Reported by PMD.
Line: 35
protected Deque<String> create() {
TestDeque<String> inner = new TestDeque<>();
Deque<String> outer = Synchronized.deque(inner, inner.mutex);
outer.add("foo"); // necessary because we try to remove elements later on
return outer;
}
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
Reported by PMD.
Line: 39
return outer;
}
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
public final Object mutex = new Integer(1); // something Serializable
@Override
public boolean offer(E o) {
Reported by PMD.
Line: 40
}
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
public final Object mutex = new Integer(1); // something Serializable
@Override
public boolean offer(E o) {
assertTrue(Thread.holdsLock(mutex));
Reported by PMD.
Line: 41
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
public final Object mutex = new Integer(1); // something Serializable
@Override
public boolean offer(E o) {
assertTrue(Thread.holdsLock(mutex));
return delegate.offer(o);
Reported by PMD.
Line: 45
@Override
public boolean offer(E o) {
assertTrue(Thread.holdsLock(mutex));
return delegate.offer(o);
}
@Override
public E poll() {
Reported by PMD.
Line: 51
@Override
public E poll() {
assertTrue(Thread.holdsLock(mutex));
return delegate.poll();
}
@Override
public E remove() {
Reported by PMD.
Line: 57
@Override
public E remove() {
assertTrue(Thread.holdsLock(mutex));
return delegate.remove();
}
@Override
public boolean remove(Object object) {
Reported by PMD.
Line: 63
@Override
public boolean remove(Object object) {
assertTrue(Thread.holdsLock(mutex));
return delegate.remove(object);
}
@Override
public E peek() {
Reported by PMD.
android/guava-tests/test/com/google/common/collect/SynchronizedDequeTest.java
78 issues
Line: 41
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
public final Object mutex = new Integer(1); // something Serializable
@Override
public boolean offer(E o) {
assertTrue(Thread.holdsLock(mutex));
return delegate.offer(o);
Reported by PMD.
Line: 35
protected Deque<String> create() {
TestDeque<String> inner = new TestDeque<>();
Deque<String> outer = Synchronized.deque(inner, inner.mutex);
outer.add("foo"); // necessary because we try to remove elements later on
return outer;
}
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
Reported by PMD.
Line: 35
protected Deque<String> create() {
TestDeque<String> inner = new TestDeque<>();
Deque<String> outer = Synchronized.deque(inner, inner.mutex);
outer.add("foo"); // necessary because we try to remove elements later on
return outer;
}
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
Reported by PMD.
Line: 39
return outer;
}
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
public final Object mutex = new Integer(1); // something Serializable
@Override
public boolean offer(E o) {
Reported by PMD.
Line: 40
}
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
public final Object mutex = new Integer(1); // something Serializable
@Override
public boolean offer(E o) {
assertTrue(Thread.holdsLock(mutex));
Reported by PMD.
Line: 41
private static final class TestDeque<E> implements Deque<E> {
private final Deque<E> delegate = Lists.newLinkedList();
public final Object mutex = new Integer(1); // something Serializable
@Override
public boolean offer(E o) {
assertTrue(Thread.holdsLock(mutex));
return delegate.offer(o);
Reported by PMD.
Line: 45
@Override
public boolean offer(E o) {
assertTrue(Thread.holdsLock(mutex));
return delegate.offer(o);
}
@Override
public E poll() {
Reported by PMD.
Line: 51
@Override
public E poll() {
assertTrue(Thread.holdsLock(mutex));
return delegate.poll();
}
@Override
public E remove() {
Reported by PMD.
Line: 57
@Override
public E remove() {
assertTrue(Thread.holdsLock(mutex));
return delegate.remove();
}
@Override
public boolean remove(Object object) {
Reported by PMD.
Line: 63
@Override
public boolean remove(Object object) {
assertTrue(Thread.holdsLock(mutex));
return delegate.remove(object);
}
@Override
public E peek() {
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java
78 issues
Line: 19
import java.util.Arrays;
/** Unit test for {@link AtomicDoubleArray}. */
public class AtomicDoubleArrayTest extends JSR166TestCase {
private static final double[] VALUES = {
Double.NEGATIVE_INFINITY,
-Double.MAX_VALUE,
(double) Long.MIN_VALUE,
Reported by PMD.
Line: 19
import java.util.Arrays;
/** Unit test for {@link AtomicDoubleArray}. */
public class AtomicDoubleArrayTest extends JSR166TestCase {
private static final double[] VALUES = {
Double.NEGATIVE_INFINITY,
-Double.MAX_VALUE,
(double) Long.MIN_VALUE,
Reported by PMD.
Line: 44
/** The notion of equality used by AtomicDoubleArray */
static boolean bitEquals(double x, double y) {
return Double.doubleToRawLongBits(x) == Double.doubleToRawLongBits(y);
}
static void assertBitEquals(double x, double y) {
assertEquals(Double.doubleToRawLongBits(x), Double.doubleToRawLongBits(y));
}
Reported by PMD.
Line: 52
}
/** constructor creates array of given size with all elements zero */
public void testConstructor() {
AtomicDoubleArray aa = new AtomicDoubleArray(SIZE);
for (int i = 0; i < SIZE; i++) {
assertBitEquals(0.0, aa.get(i));
}
}
Reported by PMD.
Line: 60
}
/** constructor with null array throws NPE */
public void testConstructor2NPE() {
double[] a = null;
try {
new AtomicDoubleArray(a);
fail();
} catch (NullPointerException success) {
Reported by PMD.
Line: 65
try {
new AtomicDoubleArray(a);
fail();
} catch (NullPointerException success) {
}
}
/** constructor with array is of same size and has all elements */
public void testConstructor2() {
Reported by PMD.
Line: 65
try {
new AtomicDoubleArray(a);
fail();
} catch (NullPointerException success) {
}
}
/** constructor with array is of same size and has all elements */
public void testConstructor2() {
Reported by PMD.
Line: 65
try {
new AtomicDoubleArray(a);
fail();
} catch (NullPointerException success) {
}
}
/** constructor with array is of same size and has all elements */
public void testConstructor2() {
Reported by PMD.
Line: 70
}
/** constructor with array is of same size and has all elements */
public void testConstructor2() {
AtomicDoubleArray aa = new AtomicDoubleArray(VALUES);
assertEquals(VALUES.length, aa.length());
for (int i = 0; i < VALUES.length; i++) {
assertBitEquals(VALUES[i], aa.get(i));
}
Reported by PMD.
Line: 70
}
/** constructor with array is of same size and has all elements */
public void testConstructor2() {
AtomicDoubleArray aa = new AtomicDoubleArray(VALUES);
assertEquals(VALUES.length, aa.length());
for (int i = 0; i < VALUES.length; i++) {
assertBitEquals(VALUES[i], aa.get(i));
}
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/AtomicDoubleArrayTest.java
78 issues
Line: 19
import java.util.Arrays;
/** Unit test for {@link AtomicDoubleArray}. */
public class AtomicDoubleArrayTest extends JSR166TestCase {
private static final double[] VALUES = {
Double.NEGATIVE_INFINITY,
-Double.MAX_VALUE,
(double) Long.MIN_VALUE,
Reported by PMD.
Line: 19
import java.util.Arrays;
/** Unit test for {@link AtomicDoubleArray}. */
public class AtomicDoubleArrayTest extends JSR166TestCase {
private static final double[] VALUES = {
Double.NEGATIVE_INFINITY,
-Double.MAX_VALUE,
(double) Long.MIN_VALUE,
Reported by PMD.
Line: 44
/** The notion of equality used by AtomicDoubleArray */
static boolean bitEquals(double x, double y) {
return Double.doubleToRawLongBits(x) == Double.doubleToRawLongBits(y);
}
static void assertBitEquals(double x, double y) {
assertEquals(Double.doubleToRawLongBits(x), Double.doubleToRawLongBits(y));
}
Reported by PMD.
Line: 52
}
/** constructor creates array of given size with all elements zero */
public void testConstructor() {
AtomicDoubleArray aa = new AtomicDoubleArray(SIZE);
for (int i = 0; i < SIZE; i++) {
assertBitEquals(0.0, aa.get(i));
}
}
Reported by PMD.
Line: 60
}
/** constructor with null array throws NPE */
public void testConstructor2NPE() {
double[] a = null;
try {
new AtomicDoubleArray(a);
fail();
} catch (NullPointerException success) {
Reported by PMD.
Line: 65
try {
new AtomicDoubleArray(a);
fail();
} catch (NullPointerException success) {
}
}
/** constructor with array is of same size and has all elements */
public void testConstructor2() {
Reported by PMD.
Line: 65
try {
new AtomicDoubleArray(a);
fail();
} catch (NullPointerException success) {
}
}
/** constructor with array is of same size and has all elements */
public void testConstructor2() {
Reported by PMD.
Line: 65
try {
new AtomicDoubleArray(a);
fail();
} catch (NullPointerException success) {
}
}
/** constructor with array is of same size and has all elements */
public void testConstructor2() {
Reported by PMD.
Line: 70
}
/** constructor with array is of same size and has all elements */
public void testConstructor2() {
AtomicDoubleArray aa = new AtomicDoubleArray(VALUES);
assertEquals(VALUES.length, aa.length());
for (int i = 0; i < VALUES.length; i++) {
assertBitEquals(VALUES[i], aa.get(i));
}
Reported by PMD.
Line: 70
}
/** constructor with array is of same size and has all elements */
public void testConstructor2() {
AtomicDoubleArray aa = new AtomicDoubleArray(VALUES);
assertEquals(VALUES.length, aa.length());
for (int i = 0; i < VALUES.length; i++) {
assertBitEquals(VALUES[i], aa.get(i));
}
Reported by PMD.