The following issues were found
android/guava-testlib/src/com/google/common/testing/NullPointerTester.java
54 issues
Line: 368
error.initCause(cause);
throw error;
} catch (IllegalAccessException e) {
throw new RuntimeException(e);
}
}
private Object[] buildParamList(Invokable<?, ?> invokable, int indexOfParamToSetToNull) {
ImmutableList<Parameter> params = invokable.getParameters();
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.Beta;
Reported by PMD.
Line: 71
*/
@Beta
@GwtIncompatible
public final class NullPointerTester {
private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
private final List<Member> ignoredMembers = Lists.newArrayList();
private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;
Reported by PMD.
Line: 71
*/
@Beta
@GwtIncompatible
public final class NullPointerTester {
private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
private final List<Member> ignoredMembers = Lists.newArrayList();
private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;
Reported by PMD.
Line: 73
@GwtIncompatible
public final class NullPointerTester {
private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
private final List<Member> ignoredMembers = Lists.newArrayList();
private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;
/**
Reported by PMD.
Line: 74
public final class NullPointerTester {
private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
private final List<Member> ignoredMembers = Lists.newArrayList();
private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;
/**
* Sets a default value that can be used for any parameter of type {@code type}. Returns this
Reported by PMD.
Line: 76
private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
private final List<Member> ignoredMembers = Lists.newArrayList();
private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;
/**
* Sets a default value that can be used for any parameter of type {@code type}. Returns this
* object.
*/
Reported by PMD.
Line: 76
private final ClassToInstanceMap<Object> defaults = MutableClassToInstanceMap.create();
private final List<Member> ignoredMembers = Lists.newArrayList();
private ExceptionTypePolicy policy = ExceptionTypePolicy.NPE_OR_UOE;
/**
* Sets a default value that can be used for any parameter of type {@code type}. Returns this
* object.
*/
Reported by PMD.
Line: 111
* Runs {@link #testConstructor} on every constructor in class {@code c} that has at least {@code
* minimalVisibility}.
*/
public void testConstructors(Class<?> c, Visibility minimalVisibility) {
for (Constructor<?> constructor : c.getDeclaredConstructors()) {
if (minimalVisibility.isVisible(constructor) && !isIgnored(constructor)) {
testConstructor(constructor);
}
}
Reported by PMD.
Line: 120
}
/** Runs {@link #testConstructor} on every public constructor in class {@code c}. */
public void testAllPublicConstructors(Class<?> c) {
testConstructors(c, Visibility.PUBLIC);
}
/**
* Runs {@link #testMethod} on every static method of class {@code c} that has at least {@code
Reported by PMD.
android/guava/src/com/google/common/collect/MinMaxPriorityQueue.java
54 issues
Line: 500
@VisibleForTesting
static boolean isEvenLevel(int index) {
int oneBased = ~~(index + 1); // for GWT
checkState(oneBased > 0, "negative index");
return (oneBased & EVEN_POWERS_OF_TWO) > (oneBased & ODD_POWERS_OF_TWO);
}
/**
Reported by PMD.
Line: 570
}
/** Bubbles a value from {@code index} up the appropriate heap if required. */
void bubbleUp(int index, E x) {
int crossOver = crossOverUp(index, x);
Heap heap;
if (crossOver == index) {
heap = this;
Reported by PMD.
Line: 588
* element ended up at.
*/
@CanIgnoreReturnValue
int bubbleUpAlternatingLevels(int index, E x) {
while (index > 2) {
int grandParentIndex = getGrandparentIndex(index);
E e = elementData(grandParentIndex);
if (ordering.compare(e, x) <= 0) {
break;
Reported by PMD.
Line: 721
* @return the position of the new hole (where the lowest grandchild moved from, that had no
* grandchild to replace it)
*/
int fillHoleAt(int index) {
int minGrandchildIndex;
while ((minGrandchildIndex = findMinGrandChild(index)) > 0) {
queue[index] = elementData(minGrandchildIndex);
index = minGrandchildIndex;
}
Reported by PMD.
Line: 869
* Advances nextCursor to the index of the first element after {@code c} that is not in {@code
* skipMe} and returns {@code size()} if there is no such element.
*/
private void nextNotInSkipMe(int c) {
if (nextCursor < c) {
if (skipMe != null) {
while (c < size() && foundAndRemovedExactReference(skipMe, elementData(c))) {
c++;
}
Reported by PMD.
Line: 104
@Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
/**
* Creates a new min-max priority queue with default settings: natural order, no maximum size, no
* initial contents, and an initial expected size of 11.
*/
Reported by PMD.
Line: 104
@Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
/**
* Creates a new min-max priority queue with default settings: natural order, no maximum size, no
* initial contents, and an initial expected size of 11.
*/
Reported by PMD.
Line: 173
*/
private static final int UNSET_EXPECTED_SIZE = -1;
private final Comparator<B> comparator;
private int expectedSize = UNSET_EXPECTED_SIZE;
private int maximumSize = Integer.MAX_VALUE;
private Builder(Comparator<B> comparator) {
this.comparator = checkNotNull(comparator);
Reported by PMD.
Line: 174
private static final int UNSET_EXPECTED_SIZE = -1;
private final Comparator<B> comparator;
private int expectedSize = UNSET_EXPECTED_SIZE;
private int maximumSize = Integer.MAX_VALUE;
private Builder(Comparator<B> comparator) {
this.comparator = checkNotNull(comparator);
}
Reported by PMD.
Line: 174
private static final int UNSET_EXPECTED_SIZE = -1;
private final Comparator<B> comparator;
private int expectedSize = UNSET_EXPECTED_SIZE;
private int maximumSize = Integer.MAX_VALUE;
private Builder(Comparator<B> comparator) {
this.comparator = checkNotNull(comparator);
}
Reported by PMD.
android/guava-tests/test/com/google/common/reflect/ImmutableTypeToInstanceMapTest.java
54 issues
Line: 43
*/
public class ImmutableTypeToInstanceMapTest extends TestCase {
@AndroidIncompatible // problem with suite builders on Android
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ImmutableTypeToInstanceMapTest.class);
suite.addTest(
Reported by PMD.
Line: 60
ImmutableTypeToInstanceMap.builder();
for (Object object : elements) {
Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
builder.put(entry.getKey(), entry.getValue());
}
return (Map) builder.build();
}
})
.named("ImmutableTypeToInstanceMap")
Reported by PMD.
Line: 60
ImmutableTypeToInstanceMap.builder();
for (Object object : elements) {
Entry<TypeToken, Object> entry = (Entry<TypeToken, Object>) object;
builder.put(entry.getKey(), entry.getValue());
}
return (Map) builder.build();
}
})
.named("ImmutableTypeToInstanceMap")
Reported by PMD.
Line: 77
return suite;
}
public void testEmpty() {
assertEquals(0, ImmutableTypeToInstanceMap.of().size());
}
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
Reported by PMD.
Line: 78
}
public void testEmpty() {
assertEquals(0, ImmutableTypeToInstanceMap.of().size());
}
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
Reported by PMD.
Line: 78
}
public void testEmpty() {
assertEquals(0, ImmutableTypeToInstanceMap.of().size());
}
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
Reported by PMD.
Line: 81
assertEquals(0, ImmutableTypeToInstanceMap.of().size());
}
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
.put(Integer.class, 0)
.put(int.class, 1)
.build();
Reported by PMD.
Line: 81
assertEquals(0, ImmutableTypeToInstanceMap.of().size());
}
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
.put(Integer.class, 0)
.put(int.class, 1)
.build();
Reported by PMD.
Line: 83
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
.put(Integer.class, 0)
.put(int.class, 1)
.build();
assertEquals(2, map.size());
Reported by PMD.
Line: 83
public void testPrimitiveAndWrapper() {
ImmutableTypeToInstanceMap<Number> map =
ImmutableTypeToInstanceMap.<Number>builder()
.put(Integer.class, 0)
.put(int.class, 1)
.build();
assertEquals(2, map.size());
Reported by PMD.
guava-tests/test/com/google/common/collect/TableCollectorsTest.java
54 issues
Line: 37
public class TableCollectorsTest {
public static final class ToImmutableTableTest extends TestCase {
public void testToImmutableTable() {
Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
collector =
TableCollectors.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
BiPredicate<ImmutableTable<String, String, Integer>, ImmutableTable<String, String, Integer>>
equivalence = pairwiseOnResultOf(ImmutableTable::cellSet);
Reported by PMD.
Line: 46
CollectorTester.of(collector, equivalence)
.expectCollects(
new ImmutableTable.Builder<String, String, Integer>()
.put("one", "uno", 1)
.put("two", "dos", 2)
.put("three", "tres", 3)
.build(),
immutableCell("one", "uno", 1),
immutableCell("two", "dos", 2),
Reported by PMD.
Line: 46
CollectorTester.of(collector, equivalence)
.expectCollects(
new ImmutableTable.Builder<String, String, Integer>()
.put("one", "uno", 1)
.put("two", "dos", 2)
.put("three", "tres", 3)
.build(),
immutableCell("one", "uno", 1),
immutableCell("two", "dos", 2),
Reported by PMD.
Line: 47
.expectCollects(
new ImmutableTable.Builder<String, String, Integer>()
.put("one", "uno", 1)
.put("two", "dos", 2)
.put("three", "tres", 3)
.build(),
immutableCell("one", "uno", 1),
immutableCell("two", "dos", 2),
immutableCell("three", "tres", 3));
Reported by PMD.
Line: 47
.expectCollects(
new ImmutableTable.Builder<String, String, Integer>()
.put("one", "uno", 1)
.put("two", "dos", 2)
.put("three", "tres", 3)
.build(),
immutableCell("one", "uno", 1),
immutableCell("two", "dos", 2),
immutableCell("three", "tres", 3));
Reported by PMD.
Line: 48
new ImmutableTable.Builder<String, String, Integer>()
.put("one", "uno", 1)
.put("two", "dos", 2)
.put("three", "tres", 3)
.build(),
immutableCell("one", "uno", 1),
immutableCell("two", "dos", 2),
immutableCell("three", "tres", 3));
}
Reported by PMD.
Line: 48
new ImmutableTable.Builder<String, String, Integer>()
.put("one", "uno", 1)
.put("two", "dos", 2)
.put("three", "tres", 3)
.build(),
immutableCell("one", "uno", 1),
immutableCell("two", "dos", 2),
immutableCell("three", "tres", 3));
}
Reported by PMD.
Line: 55
immutableCell("three", "tres", 3));
}
public void testToImmutableTableConflict() {
Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
collector =
TableCollectors.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
try {
Stream.of(immutableCell("one", "uno", 1), immutableCell("one", "uno", 2))
Reported by PMD.
Line: 60
collector =
TableCollectors.toImmutableTable(Cell::getRowKey, Cell::getColumnKey, Cell::getValue);
try {
Stream.of(immutableCell("one", "uno", 1), immutableCell("one", "uno", 2))
.collect(collector);
fail("Expected IllegalArgumentException");
} catch (IllegalArgumentException expected) {
}
}
Reported by PMD.
Line: 67
}
}
public void testToImmutableTableNullRowKey() {
Collector<Cell<String, String, Integer>, ?, ImmutableTable<String, String, Integer>>
collector =
TableCollectors.toImmutableTable(t -> null, Cell::getColumnKey, Cell::getValue);
try {
Stream.of(immutableCell("one", "uno", 1)).collect(collector);
Reported by PMD.
guava-tests/test/com/google/common/primitives/SignedBytesTest.java
54 issues
Line: 164
testSortDescending(new byte[] {-1, 1, -2, 2}, new byte[] {2, 1, -1, -2});
}
private static void testSortDescending(byte[] input, byte[] expectedOutput) {
input = Arrays.copyOf(input, input.length);
SignedBytes.sortDescending(input);
assertTrue(Arrays.equals(expectedOutput, input));
}
Reported by PMD.
Line: 171
}
private static void testSortDescending(
byte[] input, int fromIndex, int toIndex, byte[] expectedOutput) {
input = Arrays.copyOf(input, input.length);
SignedBytes.sortDescending(input, fromIndex, toIndex);
assertTrue(Arrays.equals(expectedOutput, input));
}
Reported by PMD.
Line: 36
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("cast") // redundant casts are intentional and harmless
public class SignedBytesTest extends TestCase {
private static final byte[] EMPTY = {};
private static final byte[] ARRAY1 = {(byte) 1};
private static final byte LEAST = Byte.MIN_VALUE;
private static final byte GREATEST = Byte.MAX_VALUE;
Reported by PMD.
Line: 45
private static final byte[] VALUES = {LEAST, -1, 0, 1, GREATEST};
public void testCheckedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.checkedCast((long) value));
}
assertCastFails(GREATEST + 1L);
assertCastFails(LEAST - 1L);
Reported by PMD.
Line: 45
private static final byte[] VALUES = {LEAST, -1, 0, 1, GREATEST};
public void testCheckedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.checkedCast((long) value));
}
assertCastFails(GREATEST + 1L);
assertCastFails(LEAST - 1L);
Reported by PMD.
Line: 47
public void testCheckedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.checkedCast((long) value));
}
assertCastFails(GREATEST + 1L);
assertCastFails(LEAST - 1L);
assertCastFails(Long.MAX_VALUE);
assertCastFails(Long.MIN_VALUE);
Reported by PMD.
Line: 55
assertCastFails(Long.MIN_VALUE);
}
public void testSaturatedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.saturatedCast((long) value));
}
assertEquals(GREATEST, SignedBytes.saturatedCast(GREATEST + 1L));
assertEquals(LEAST, SignedBytes.saturatedCast(LEAST - 1L));
Reported by PMD.
Line: 55
assertCastFails(Long.MIN_VALUE);
}
public void testSaturatedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.saturatedCast((long) value));
}
assertEquals(GREATEST, SignedBytes.saturatedCast(GREATEST + 1L));
assertEquals(LEAST, SignedBytes.saturatedCast(LEAST - 1L));
Reported by PMD.
Line: 57
public void testSaturatedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.saturatedCast((long) value));
}
assertEquals(GREATEST, SignedBytes.saturatedCast(GREATEST + 1L));
assertEquals(LEAST, SignedBytes.saturatedCast(LEAST - 1L));
assertEquals(GREATEST, SignedBytes.saturatedCast(Long.MAX_VALUE));
assertEquals(LEAST, SignedBytes.saturatedCast(Long.MIN_VALUE));
Reported by PMD.
Line: 59
for (byte value : VALUES) {
assertEquals(value, SignedBytes.saturatedCast((long) value));
}
assertEquals(GREATEST, SignedBytes.saturatedCast(GREATEST + 1L));
assertEquals(LEAST, SignedBytes.saturatedCast(LEAST - 1L));
assertEquals(GREATEST, SignedBytes.saturatedCast(Long.MAX_VALUE));
assertEquals(LEAST, SignedBytes.saturatedCast(Long.MIN_VALUE));
}
Reported by PMD.
android/guava-tests/test/com/google/common/primitives/SignedBytesTest.java
54 issues
Line: 164
testSortDescending(new byte[] {-1, 1, -2, 2}, new byte[] {2, 1, -1, -2});
}
private static void testSortDescending(byte[] input, byte[] expectedOutput) {
input = Arrays.copyOf(input, input.length);
SignedBytes.sortDescending(input);
assertTrue(Arrays.equals(expectedOutput, input));
}
Reported by PMD.
Line: 171
}
private static void testSortDescending(
byte[] input, int fromIndex, int toIndex, byte[] expectedOutput) {
input = Arrays.copyOf(input, input.length);
SignedBytes.sortDescending(input, fromIndex, toIndex);
assertTrue(Arrays.equals(expectedOutput, input));
}
Reported by PMD.
Line: 36
*/
@GwtCompatible(emulated = true)
@SuppressWarnings("cast") // redundant casts are intentional and harmless
public class SignedBytesTest extends TestCase {
private static final byte[] EMPTY = {};
private static final byte[] ARRAY1 = {(byte) 1};
private static final byte LEAST = Byte.MIN_VALUE;
private static final byte GREATEST = Byte.MAX_VALUE;
Reported by PMD.
Line: 45
private static final byte[] VALUES = {LEAST, -1, 0, 1, GREATEST};
public void testCheckedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.checkedCast((long) value));
}
assertCastFails(GREATEST + 1L);
assertCastFails(LEAST - 1L);
Reported by PMD.
Line: 45
private static final byte[] VALUES = {LEAST, -1, 0, 1, GREATEST};
public void testCheckedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.checkedCast((long) value));
}
assertCastFails(GREATEST + 1L);
assertCastFails(LEAST - 1L);
Reported by PMD.
Line: 47
public void testCheckedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.checkedCast((long) value));
}
assertCastFails(GREATEST + 1L);
assertCastFails(LEAST - 1L);
assertCastFails(Long.MAX_VALUE);
assertCastFails(Long.MIN_VALUE);
Reported by PMD.
Line: 55
assertCastFails(Long.MIN_VALUE);
}
public void testSaturatedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.saturatedCast((long) value));
}
assertEquals(GREATEST, SignedBytes.saturatedCast(GREATEST + 1L));
assertEquals(LEAST, SignedBytes.saturatedCast(LEAST - 1L));
Reported by PMD.
Line: 55
assertCastFails(Long.MIN_VALUE);
}
public void testSaturatedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.saturatedCast((long) value));
}
assertEquals(GREATEST, SignedBytes.saturatedCast(GREATEST + 1L));
assertEquals(LEAST, SignedBytes.saturatedCast(LEAST - 1L));
Reported by PMD.
Line: 57
public void testSaturatedCast() {
for (byte value : VALUES) {
assertEquals(value, SignedBytes.saturatedCast((long) value));
}
assertEquals(GREATEST, SignedBytes.saturatedCast(GREATEST + 1L));
assertEquals(LEAST, SignedBytes.saturatedCast(LEAST - 1L));
assertEquals(GREATEST, SignedBytes.saturatedCast(Long.MAX_VALUE));
assertEquals(LEAST, SignedBytes.saturatedCast(Long.MIN_VALUE));
Reported by PMD.
Line: 59
for (byte value : VALUES) {
assertEquals(value, SignedBytes.saturatedCast((long) value));
}
assertEquals(GREATEST, SignedBytes.saturatedCast(GREATEST + 1L));
assertEquals(LEAST, SignedBytes.saturatedCast(LEAST - 1L));
assertEquals(GREATEST, SignedBytes.saturatedCast(Long.MAX_VALUE));
assertEquals(LEAST, SignedBytes.saturatedCast(Long.MIN_VALUE));
}
Reported by PMD.
guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java
54 issues
Line: 38
*/
@GwtCompatible(emulated = true)
public class FutureCallbackTest extends TestCase {
public void testSameThreadSuccess() {
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
Reported by PMD.
Line: 38
*/
@GwtCompatible(emulated = true)
public class FutureCallbackTest extends TestCase {
public void testSameThreadSuccess() {
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
Reported by PMD.
Line: 40
public class FutureCallbackTest extends TestCase {
public void testSameThreadSuccess() {
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
public void testExecutorSuccess() {
Reported by PMD.
Line: 42
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
public void testExecutorSuccess() {
CountingSameThreadExecutor ex = new CountingSameThreadExecutor();
SettableFuture<String> f = SettableFuture.create();
Reported by PMD.
Line: 45
f.set("foo");
}
public void testExecutorSuccess() {
CountingSameThreadExecutor ex = new CountingSameThreadExecutor();
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
Futures.addCallback(f, callback, ex);
f.set("foo");
Reported by PMD.
Line: 50
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
Futures.addCallback(f, callback, ex);
f.set("foo");
assertEquals(1, ex.runCount);
}
// Error cases
public void testSameThreadExecutionException() {
Reported by PMD.
Line: 51
MockCallback callback = new MockCallback("foo");
Futures.addCallback(f, callback, ex);
f.set("foo");
assertEquals(1, ex.runCount);
}
// Error cases
public void testSameThreadExecutionException() {
SettableFuture<String> f = SettableFuture.create();
Reported by PMD.
Line: 55
}
// Error cases
public void testSameThreadExecutionException() {
SettableFuture<String> f = SettableFuture.create();
Exception e = new IllegalArgumentException("foo not found");
MockCallback callback = new MockCallback(e);
addCallback(f, callback, directExecutor());
f.setException(e);
Reported by PMD.
Line: 55
}
// Error cases
public void testSameThreadExecutionException() {
SettableFuture<String> f = SettableFuture.create();
Exception e = new IllegalArgumentException("foo not found");
MockCallback callback = new MockCallback(e);
addCallback(f, callback, directExecutor());
f.setException(e);
Reported by PMD.
Line: 60
Exception e = new IllegalArgumentException("foo not found");
MockCallback callback = new MockCallback(e);
addCallback(f, callback, directExecutor());
f.setException(e);
}
public void testCancel() {
SettableFuture<String> f = SettableFuture.create();
FutureCallback<String> callback =
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/UninterruptibleFutureTest.java
54 issues
Line: 104
fail("expected to be interrupted");
} catch (InterruptedException expected) {
} catch (TimeoutException e) {
throw new RuntimeException(e);
}
// we were interrupted, but it's been cleared now
assertFalse(Thread.interrupted());
Reported by PMD.
Line: 114
try {
assertTrue(delayedFuture.get());
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
assertTrue(sleeper.completed);
}
Reported by PMD.
Line: 43
* @author Kevin Bourrillion
* @author Chris Povirk
*/
public class UninterruptibleFutureTest extends TestCase {
private SleepingRunnable sleeper;
private Future<Boolean> delayedFuture;
private final TearDownStack tearDownStack = new TearDownStack();
Reported by PMD.
Line: 44
* @author Chris Povirk
*/
public class UninterruptibleFutureTest extends TestCase {
private SleepingRunnable sleeper;
private Future<Boolean> delayedFuture;
private final TearDownStack tearDownStack = new TearDownStack();
@Override
Reported by PMD.
Line: 45
*/
public class UninterruptibleFutureTest extends TestCase {
private SleepingRunnable sleeper;
private Future<Boolean> delayedFuture;
private final TearDownStack tearDownStack = new TearDownStack();
@Override
protected void setUp() {
Reported by PMD.
Line: 47
private SleepingRunnable sleeper;
private Future<Boolean> delayedFuture;
private final TearDownStack tearDownStack = new TearDownStack();
@Override
protected void setUp() {
final ExecutorService executor = Executors.newSingleThreadExecutor();
tearDownStack.addTearDown(
Reported by PMD.
Line: 49
private final TearDownStack tearDownStack = new TearDownStack();
@Override
protected void setUp() {
final ExecutorService executor = Executors.newSingleThreadExecutor();
tearDownStack.addTearDown(
new TearDown() {
@Override
Reported by PMD.
Line: 54
final ExecutorService executor = Executors.newSingleThreadExecutor();
tearDownStack.addTearDown(
new TearDown() {
@Override
public void tearDown() {
executor.shutdownNow();
}
});
sleeper = new SleepingRunnable(1000);
Reported by PMD.
Line: 60
}
});
sleeper = new SleepingRunnable(1000);
delayedFuture = executor.submit(sleeper, true);
tearDownStack.addTearDown(
new TearDown() {
@Override
public void tearDown() {
Reported by PMD.
Line: 64
tearDownStack.addTearDown(
new TearDown() {
@Override
public void tearDown() {
Thread.interrupted();
}
});
}
Reported by PMD.
android/guava-tests/test/com/google/common/util/concurrent/FutureCallbackTest.java
54 issues
Line: 38
*/
@GwtCompatible(emulated = true)
public class FutureCallbackTest extends TestCase {
public void testSameThreadSuccess() {
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
Reported by PMD.
Line: 38
*/
@GwtCompatible(emulated = true)
public class FutureCallbackTest extends TestCase {
public void testSameThreadSuccess() {
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
Reported by PMD.
Line: 40
public class FutureCallbackTest extends TestCase {
public void testSameThreadSuccess() {
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
public void testExecutorSuccess() {
Reported by PMD.
Line: 42
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
addCallback(f, callback, directExecutor());
f.set("foo");
}
public void testExecutorSuccess() {
CountingSameThreadExecutor ex = new CountingSameThreadExecutor();
SettableFuture<String> f = SettableFuture.create();
Reported by PMD.
Line: 45
f.set("foo");
}
public void testExecutorSuccess() {
CountingSameThreadExecutor ex = new CountingSameThreadExecutor();
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
Futures.addCallback(f, callback, ex);
f.set("foo");
Reported by PMD.
Line: 50
SettableFuture<String> f = SettableFuture.create();
MockCallback callback = new MockCallback("foo");
Futures.addCallback(f, callback, ex);
f.set("foo");
assertEquals(1, ex.runCount);
}
// Error cases
public void testSameThreadExecutionException() {
Reported by PMD.
Line: 51
MockCallback callback = new MockCallback("foo");
Futures.addCallback(f, callback, ex);
f.set("foo");
assertEquals(1, ex.runCount);
}
// Error cases
public void testSameThreadExecutionException() {
SettableFuture<String> f = SettableFuture.create();
Reported by PMD.
Line: 55
}
// Error cases
public void testSameThreadExecutionException() {
SettableFuture<String> f = SettableFuture.create();
Exception e = new IllegalArgumentException("foo not found");
MockCallback callback = new MockCallback(e);
addCallback(f, callback, directExecutor());
f.setException(e);
Reported by PMD.
Line: 55
}
// Error cases
public void testSameThreadExecutionException() {
SettableFuture<String> f = SettableFuture.create();
Exception e = new IllegalArgumentException("foo not found");
MockCallback callback = new MockCallback(e);
addCallback(f, callback, directExecutor());
f.setException(e);
Reported by PMD.
Line: 60
Exception e = new IllegalArgumentException("foo not found");
MockCallback callback = new MockCallback(e);
addCallback(f, callback, directExecutor());
f.setException(e);
}
public void testCancel() {
SettableFuture<String> f = SettableFuture.create();
FutureCallback<String> callback =
Reported by PMD.
guava/src/com/google/common/collect/MinMaxPriorityQueue.java
54 issues
Line: 500
@VisibleForTesting
static boolean isEvenLevel(int index) {
int oneBased = ~~(index + 1); // for GWT
checkState(oneBased > 0, "negative index");
return (oneBased & EVEN_POWERS_OF_TWO) > (oneBased & ODD_POWERS_OF_TWO);
}
/**
Reported by PMD.
Line: 570
}
/** Bubbles a value from {@code index} up the appropriate heap if required. */
void bubbleUp(int index, E x) {
int crossOver = crossOverUp(index, x);
Heap heap;
if (crossOver == index) {
heap = this;
Reported by PMD.
Line: 588
* element ended up at.
*/
@CanIgnoreReturnValue
int bubbleUpAlternatingLevels(int index, E x) {
while (index > 2) {
int grandParentIndex = getGrandparentIndex(index);
E e = elementData(grandParentIndex);
if (ordering.compare(e, x) <= 0) {
break;
Reported by PMD.
Line: 721
* @return the position of the new hole (where the lowest grandchild moved from, that had no
* grandchild to replace it)
*/
int fillHoleAt(int index) {
int minGrandchildIndex;
while ((minGrandchildIndex = findMinGrandChild(index)) > 0) {
queue[index] = elementData(minGrandchildIndex);
index = minGrandchildIndex;
}
Reported by PMD.
Line: 869
* Advances nextCursor to the index of the first element after {@code c} that is not in {@code
* skipMe} and returns {@code size()} if there is no such element.
*/
private void nextNotInSkipMe(int c) {
if (nextCursor < c) {
if (skipMe != null) {
while (c < size() && foundAndRemovedExactReference(skipMe, elementData(c))) {
c++;
}
Reported by PMD.
Line: 104
@Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
/**
* Creates a new min-max priority queue with default settings: natural order, no maximum size, no
* initial contents, and an initial expected size of 11.
*/
Reported by PMD.
Line: 104
@Beta
@GwtCompatible
@ElementTypesAreNonnullByDefault
public final class MinMaxPriorityQueue<E> extends AbstractQueue<E> {
/**
* Creates a new min-max priority queue with default settings: natural order, no maximum size, no
* initial contents, and an initial expected size of 11.
*/
Reported by PMD.
Line: 173
*/
private static final int UNSET_EXPECTED_SIZE = -1;
private final Comparator<B> comparator;
private int expectedSize = UNSET_EXPECTED_SIZE;
private int maximumSize = Integer.MAX_VALUE;
private Builder(Comparator<B> comparator) {
this.comparator = checkNotNull(comparator);
Reported by PMD.
Line: 174
private static final int UNSET_EXPECTED_SIZE = -1;
private final Comparator<B> comparator;
private int expectedSize = UNSET_EXPECTED_SIZE;
private int maximumSize = Integer.MAX_VALUE;
private Builder(Comparator<B> comparator) {
this.comparator = checkNotNull(comparator);
}
Reported by PMD.
Line: 174
private static final int UNSET_EXPECTED_SIZE = -1;
private final Comparator<B> comparator;
private int expectedSize = UNSET_EXPECTED_SIZE;
private int maximumSize = Integer.MAX_VALUE;
private Builder(Comparator<B> comparator) {
this.comparator = checkNotNull(comparator);
}
Reported by PMD.