The following issues were found
guava/src/com/google/common/io/ByteSource.java
69 issues
Line: 641
}
@Override
public ByteSource slice(long offset, long length) {
checkArgument(offset >= 0, "offset (%s) may not be negative", offset);
checkArgument(length >= 0, "length (%s) may not be negative", length);
offset = Math.min(offset, this.length);
length = Math.min(length, this.length - offset);
Reported by PMD.
Line: 641
}
@Override
public ByteSource slice(long offset, long length) {
checkArgument(offset >= 0, "offset (%s) may not be negative", offset);
checkArgument(length >= 0, "length (%s) may not be negative", length);
offset = Math.min(offset, this.length);
length = Math.min(length, this.length - offset);
Reported by PMD.
Line: 15
* the License.
*/
package com.google.common.io;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.io.ByteStreams.createBuffer;
import static com.google.common.io.ByteStreams.skipUpTo;
Reported by PMD.
Line: 78
*/
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public abstract class ByteSource {
/** Constructor for use by subclasses. */
protected ByteSource() {}
/**
Reported by PMD.
Line: 153
*/
public boolean isEmpty() throws IOException {
Optional<Long> sizeIfKnown = sizeIfKnown();
if (sizeIfKnown.isPresent()) {
return sizeIfKnown.get() == 0L;
}
Closer closer = Closer.create();
try {
InputStream in = closer.register(openStream());
Reported by PMD.
Line: 158
}
Closer closer = Closer.create();
try {
InputStream in = closer.register(openStream());
return in.read() == -1;
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
Reported by PMD.
Line: 159
Closer closer = Closer.create();
try {
InputStream in = closer.register(openStream());
return in.read() == -1;
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
Reported by PMD.
Line: 160
try {
InputStream in = closer.register(openStream());
return in.read() == -1;
} catch (Throwable e) {
throw closer.rethrow(e);
} finally {
closer.close();
}
}
Reported by PMD.
Line: 207
*/
public long size() throws IOException {
Optional<Long> sizeIfKnown = sizeIfKnown();
if (sizeIfKnown.isPresent()) {
return sizeIfKnown.get();
}
Closer closer = Closer.create();
try {
Reported by PMD.
Line: 213
Closer closer = Closer.create();
try {
InputStream in = closer.register(openStream());
return countBySkipping(in);
} catch (IOException e) {
// skip may not be supported... at any rate, try reading
} finally {
closer.close();
Reported by PMD.
guava-testlib/src/com/google/common/testing/FreshValueGenerator.java
69 issues
Line: 278
return generator.invoke(this, args);
} catch (InvocationTargetException e) {
throwIfUnchecked(e.getCause());
throw new RuntimeException(e.getCause());
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
Reported by PMD.
Line: 281
throw new RuntimeException(e.getCause());
} catch (Exception e) {
throwIfUnchecked(e);
throw new RuntimeException(e);
}
}
private final class FreshInvocationHandler extends AbstractInvocationHandler {
private final int identity = generateInt();
Reported by PMD.
Line: 417
}
@Generates
short generateShort() {
return (short) generateInt();
}
@Generates
Short generateShortObject() {
Reported by PMD.
Line: 383
@Generates
Integer generateInteger() {
return new Integer(generateInt());
}
@Generates
long generateLong() {
return generateInt();
Reported by PMD.
Line: 393
@Generates
Long generateLongObject() {
return new Long(generateLong());
}
@Generates
float generateFloat() {
return generateInt();
Reported by PMD.
Line: 423
@Generates
Short generateShortObject() {
return new Short(generateShort());
}
@Generates
byte generateByte() {
return (byte) generateInt();
Reported by PMD.
Line: 433
@Generates
Byte generateByteObject() {
return new Byte(generateByte());
}
@Generates
char generateChar() {
return generateString().charAt(0);
Reported by PMD.
Line: 453
@Generates
Boolean generateBooleanObject() {
return new Boolean(generateBoolean());
}
@Generates
UnsignedInteger generateUnsignedInteger() {
return UnsignedInteger.fromIntBits(generateInt());
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
Line: 17
* limitations under the License.
*/
package com.google.common.testing;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.base.Throwables.throwIfUnchecked;
import com.google.common.annotations.GwtIncompatible;
Reported by PMD.
guava-tests/test/com/google/common/io/CharStreamsTest.java
69 issues
Line: 36
*
* @author Chris Nokleberg
*/
public class CharStreamsTest extends IoTestCase {
private static final String TEXT = "The quick brown fox jumped over the lazy dog.";
public void testToString() throws IOException {
assertEquals(TEXT, CharStreams.toString(new StringReader(TEXT)));
Reported by PMD.
Line: 40
private static final String TEXT = "The quick brown fox jumped over the lazy dog.";
public void testToString() throws IOException {
assertEquals(TEXT, CharStreams.toString(new StringReader(TEXT)));
}
public void testReadLines() throws IOException {
List<String> lines = CharStreams.readLines(new StringReader("a\nb\nc"));
Reported by PMD.
Line: 44
assertEquals(TEXT, CharStreams.toString(new StringReader(TEXT)));
}
public void testReadLines() throws IOException {
List<String> lines = CharStreams.readLines(new StringReader("a\nb\nc"));
assertEquals(ImmutableList.of("a", "b", "c"), lines);
}
public void testReadLines_withLineProcessor() throws IOException {
Reported by PMD.
Line: 49
assertEquals(ImmutableList.of("a", "b", "c"), lines);
}
public void testReadLines_withLineProcessor() throws IOException {
String text = "a\nb\nc";
// Test a LineProcessor that always returns false.
Reader r = new StringReader(text);
LineProcessor<Integer> alwaysFalse =
Reported by PMD.
Line: 49
assertEquals(ImmutableList.of("a", "b", "c"), lines);
}
public void testReadLines_withLineProcessor() throws IOException {
String text = "a\nb\nc";
// Test a LineProcessor that always returns false.
Reader r = new StringReader(text);
LineProcessor<Integer> alwaysFalse =
Reported by PMD.
Line: 53
String text = "a\nb\nc";
// Test a LineProcessor that always returns false.
Reader r = new StringReader(text);
LineProcessor<Integer> alwaysFalse =
new LineProcessor<Integer>() {
int seen;
@Override
Reported by PMD.
Line: 72
assertEquals(
"processLine was called more than once",
1,
CharStreams.readLines(r, alwaysFalse).intValue());
// Test a LineProcessor that always returns true.
r = new StringReader(text);
LineProcessor<Integer> alwaysTrue =
new LineProcessor<Integer>() {
Reported by PMD.
Line: 94
assertEquals(
"processLine was not called for all the lines",
3,
CharStreams.readLines(r, alwaysTrue).intValue());
// Test a LineProcessor that is conditional.
r = new StringReader(text);
final StringBuilder sb = new StringBuilder();
LineProcessor<Integer> conditional =
Reported by PMD.
Line: 115
return seen;
}
};
assertEquals(2, CharStreams.readLines(r, conditional).intValue());
assertEquals("ab", sb.toString());
}
public void testSkipFully_EOF() throws IOException {
Reader reader = new StringReader("abcde");
Reported by PMD.
Line: 119
assertEquals("ab", sb.toString());
}
public void testSkipFully_EOF() throws IOException {
Reader reader = new StringReader("abcde");
try {
CharStreams.skipFully(reader, 6);
fail("expected EOFException");
} catch (EOFException expected) {
Reported by PMD.
guava-tests/test/com/google/common/cache/LocalCacheMapComputeTest.java
69 issues
Line: 192
.compute(
key,
(k, v) -> {
throw new RuntimeException();
});
});
fail("Should not get here");
} catch (RuntimeException ex) {
}
Reported by PMD.
Line: 34
/** Test Java8 map.compute in concurrent cache context. */
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
Reported by PMD.
Line: 34
/** Test Java8 map.compute in concurrent cache context. */
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
Reported by PMD.
Line: 35
/** Test Java8 map.compute in concurrent cache context. */
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
Reported by PMD.
Line: 35
/** Test Java8 map.compute in concurrent cache context. */
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
Reported by PMD.
Line: 36
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
IntStream.range(0, count).parallel().forEach(consumer);
Reported by PMD.
Line: 36
public class LocalCacheMapComputeTest extends TestCase {
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
IntStream.range(0, count).parallel().forEach(consumer);
Reported by PMD.
Line: 37
final int count = 10000;
final String delimiter = "-";
final String key = "key";
Cache<String, String> cache;
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
IntStream.range(0, count).parallel().forEach(consumer);
}
Reported by PMD.
Line: 41
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
IntStream.range(0, count).parallel().forEach(consumer);
}
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
Line: 41
// helper
private static void doParallelCacheOp(int count, IntConsumer consumer) {
IntStream.range(0, count).parallel().forEach(consumer);
}
@Override
public void setUp() throws Exception {
super.setUp();
Reported by PMD.
guava-tests/test/com/google/common/cache/CacheTesting.java
68 issues
Line: 15
* the License.
*/
package com.google.common.cache;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 72
Preconditions.checkState(valueRef instanceof Reference);
Reference<V> ref = (Reference<V>) valueRef;
if (ref != null) {
ref.clear();
}
}
}
/**
Reported by PMD.
Line: 97
checkNotNull(cache);
checkNotNull(key);
LocalCache<K, V> map = toLocalCache(cache);
return map.getEntry(key);
}
/**
* Forces the segment containing the given {@code key} to expand (see {@link Segment#expand()}.
*/
Reported by PMD.
Line: 107
checkNotNull(cache);
checkNotNull(key);
LocalCache<K, V> map = toLocalCache(cache);
int hash = map.hash(key);
Segment<K, V> segment = map.segmentFor(hash);
segment.expand();
}
/**
Reported by PMD.
Line: 108
checkNotNull(key);
LocalCache<K, V> map = toLocalCache(cache);
int hash = map.hash(key);
Segment<K, V> segment = map.segmentFor(hash);
segment.expand();
}
/**
* Gets the {@link LocalCache} used by the given {@link Cache}, if any, or throws an
Reported by PMD.
android/guava-testlib/test/com/google/common/testing/GcFinalizationTest.java
68 issues
Line: 36
* @author mike nonemacher
*/
public class GcFinalizationTest extends TestCase {
// ----------------------------------------------------------------
// Ordinary tests of successful method execution
// ----------------------------------------------------------------
Reported by PMD.
Line: 42
// Ordinary tests of successful method execution
// ----------------------------------------------------------------
public void testAwait_CountDownLatch() {
final CountDownLatch latch = new CountDownLatch(1);
Object x =
new Object() {
@Override
protected void finalize() {
Reported by PMD.
Line: 44
public void testAwait_CountDownLatch() {
final CountDownLatch latch = new CountDownLatch(1);
Object x =
new Object() {
@Override
protected void finalize() {
latch.countDown();
}
Reported by PMD.
Line: 45
public void testAwait_CountDownLatch() {
final CountDownLatch latch = new CountDownLatch(1);
Object x =
new Object() {
@Override
protected void finalize() {
latch.countDown();
}
};
Reported by PMD.
Line: 48
new Object() {
@Override
protected void finalize() {
latch.countDown();
}
};
x = null; // Hint to the JIT that x is unreachable
GcFinalization.await(latch);
assertEquals(0, latch.getCount());
Reported by PMD.
Line: 51
latch.countDown();
}
};
x = null; // Hint to the JIT that x is unreachable
GcFinalization.await(latch);
assertEquals(0, latch.getCount());
}
public void testAwaitDone_Future() {
Reported by PMD.
Line: 51
latch.countDown();
}
};
x = null; // Hint to the JIT that x is unreachable
GcFinalization.await(latch);
assertEquals(0, latch.getCount());
}
public void testAwaitDone_Future() {
Reported by PMD.
Line: 53
};
x = null; // Hint to the JIT that x is unreachable
GcFinalization.await(latch);
assertEquals(0, latch.getCount());
}
public void testAwaitDone_Future() {
final SettableFuture<Void> future = SettableFuture.create();
Object x =
Reported by PMD.
Line: 56
assertEquals(0, latch.getCount());
}
public void testAwaitDone_Future() {
final SettableFuture<Void> future = SettableFuture.create();
Object x =
new Object() {
@Override
protected void finalize() {
Reported by PMD.
Line: 56
assertEquals(0, latch.getCount());
}
public void testAwaitDone_Future() {
final SettableFuture<Void> future = SettableFuture.create();
Object x =
new Object() {
@Override
protected void finalize() {
Reported by PMD.
guava/src/com/google/common/collect/ImmutableRangeSet.java
68 issues
Line: 52
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
Reported by PMD.
Line: 52
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
Reported by PMD.
Line: 52
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
Reported by PMD.
Line: 52
@Beta
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
Reported by PMD.
Line: 53
@GwtIncompatible
@ElementTypesAreNonnullByDefault
public final class ImmutableRangeSet<C extends Comparable> extends AbstractRangeSet<C>
implements Serializable {
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
private static final ImmutableRangeSet<Comparable<?>> ALL =
Reported by PMD.
Line: 58
private static final ImmutableRangeSet<Comparable<?>> EMPTY =
new ImmutableRangeSet<>(ImmutableList.<Range<Comparable<?>>>of());
private static final ImmutableRangeSet<Comparable<?>> ALL =
new ImmutableRangeSet<>(ImmutableList.of(Range.<Comparable<?>>all()));
/**
* Returns a {@code Collector} that accumulates the input elements into a new {@code
* ImmutableRangeSet}. As in {@link Builder}, overlapping ranges are not permitted and adjacent
Reported by PMD.
Line: 78
*
* <p><b>Performance note:</b> the instance returned is a singleton.
*/
@SuppressWarnings("unchecked")
public static <C extends Comparable> ImmutableRangeSet<C> of() {
return (ImmutableRangeSet<C>) EMPTY;
}
/**
Reported by PMD.
Line: 115
if (rangeSet instanceof ImmutableRangeSet) {
ImmutableRangeSet<C> immutableRangeSet = (ImmutableRangeSet<C>) rangeSet;
if (!immutableRangeSet.isPartialView()) {
return immutableRangeSet;
}
}
return new ImmutableRangeSet<C>(ImmutableList.copyOf(rangeSet.asRanges()));
}
Reported by PMD.
Line: 168
ANY_PRESENT,
NEXT_HIGHER);
if (ceilingIndex < ranges.size()
&& ranges.get(ceilingIndex).isConnected(otherRange)
&& !ranges.get(ceilingIndex).intersection(otherRange).isEmpty()) {
return true;
}
return ceilingIndex > 0
&& ranges.get(ceilingIndex - 1).isConnected(otherRange)
Reported by PMD.
Line: 169
NEXT_HIGHER);
if (ceilingIndex < ranges.size()
&& ranges.get(ceilingIndex).isConnected(otherRange)
&& !ranges.get(ceilingIndex).intersection(otherRange).isEmpty()) {
return true;
}
return ceilingIndex > 0
&& ranges.get(ceilingIndex - 1).isConnected(otherRange)
&& !ranges.get(ceilingIndex - 1).intersection(otherRange).isEmpty();
Reported by PMD.
android/guava-tests/test/com/google/common/collect/ForwardingMapTest.java
68 issues
Line: 17
* limitations under the License.
*/
package com.google.common.collect;
import static java.lang.reflect.Modifier.STATIC;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.atLeast;
import static org.mockito.Mockito.mock;
Reported by PMD.
Line: 58
* @author Louis Wasserman
*/
public class ForwardingMapTest extends TestCase {
static class StandardImplForwardingMap<K, V> extends ForwardingMap<K, V> {
private final Map<K, V> backingMap;
StandardImplForwardingMap(Map<K, V> backingMap) {
this.backingMap = backingMap;
}
Reported by PMD.
Line: 59
*/
public class ForwardingMapTest extends TestCase {
static class StandardImplForwardingMap<K, V> extends ForwardingMap<K, V> {
private final Map<K, V> backingMap;
StandardImplForwardingMap(Map<K, V> backingMap) {
this.backingMap = backingMap;
}
Reported by PMD.
Line: 120
return new StandardEntrySet() {
@Override
public Iterator<Entry<K, V>> iterator() {
return delegate().entrySet().iterator();
}
};
}
@Override
Reported by PMD.
Line: 120
return new StandardEntrySet() {
@Override
public Iterator<Entry<K, V>> iterator() {
return delegate().entrySet().iterator();
}
};
}
@Override
Reported by PMD.
Line: 136
}
}
public static Test suite() {
TestSuite suite = new TestSuite();
suite.addTestSuite(ForwardingMapTest.class);
suite.addTest(
MapTestSuiteBuilder.using(
Reported by PMD.
Line: 187
return suite;
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
Map.class,
new Function<Map, Map>() {
Reported by PMD.
Line: 187
return suite;
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
Map.class,
new Function<Map, Map>() {
Reported by PMD.
Line: 188
}
@SuppressWarnings({"rawtypes", "unchecked"})
public void testForwarding() {
new ForwardingWrapperTester()
.testForwarding(
Map.class,
new Function<Map, Map>() {
@Override
Reported by PMD.
Line: 200
});
}
public void testEquals() {
Map<Integer, String> map1 = ImmutableMap.of(1, "one");
Map<Integer, String> map2 = ImmutableMap.of(2, "two");
new EqualsTester()
.addEqualityGroup(map1, wrap(map1), wrap(map1))
.addEqualityGroup(map2, wrap(map2))
Reported by PMD.
guava-testlib/test/com/google/common/testing/GcFinalizationTest.java
68 issues
Line: 36
* @author mike nonemacher
*/
public class GcFinalizationTest extends TestCase {
// ----------------------------------------------------------------
// Ordinary tests of successful method execution
// ----------------------------------------------------------------
Reported by PMD.
Line: 42
// Ordinary tests of successful method execution
// ----------------------------------------------------------------
public void testAwait_CountDownLatch() {
final CountDownLatch latch = new CountDownLatch(1);
Object x =
new Object() {
@Override
protected void finalize() {
Reported by PMD.
Line: 44
public void testAwait_CountDownLatch() {
final CountDownLatch latch = new CountDownLatch(1);
Object x =
new Object() {
@Override
protected void finalize() {
latch.countDown();
}
Reported by PMD.
Line: 45
public void testAwait_CountDownLatch() {
final CountDownLatch latch = new CountDownLatch(1);
Object x =
new Object() {
@Override
protected void finalize() {
latch.countDown();
}
};
Reported by PMD.
Line: 48
new Object() {
@Override
protected void finalize() {
latch.countDown();
}
};
x = null; // Hint to the JIT that x is unreachable
GcFinalization.await(latch);
assertEquals(0, latch.getCount());
Reported by PMD.
Line: 51
latch.countDown();
}
};
x = null; // Hint to the JIT that x is unreachable
GcFinalization.await(latch);
assertEquals(0, latch.getCount());
}
public void testAwaitDone_Future() {
Reported by PMD.
Line: 51
latch.countDown();
}
};
x = null; // Hint to the JIT that x is unreachable
GcFinalization.await(latch);
assertEquals(0, latch.getCount());
}
public void testAwaitDone_Future() {
Reported by PMD.
Line: 53
};
x = null; // Hint to the JIT that x is unreachable
GcFinalization.await(latch);
assertEquals(0, latch.getCount());
}
public void testAwaitDone_Future() {
final SettableFuture<Void> future = SettableFuture.create();
Object x =
Reported by PMD.
Line: 56
assertEquals(0, latch.getCount());
}
public void testAwaitDone_Future() {
final SettableFuture<Void> future = SettableFuture.create();
Object x =
new Object() {
@Override
protected void finalize() {
Reported by PMD.
Line: 56
assertEquals(0, latch.getCount());
}
public void testAwaitDone_Future() {
final SettableFuture<Void> future = SettableFuture.create();
Object x =
new Object() {
@Override
protected void finalize() {
Reported by PMD.
android/guava-tests/test/com/google/common/cache/CacheTesting.java
68 issues
Line: 15
* the License.
*/
package com.google.common.cache;
import static com.google.common.base.Preconditions.checkNotNull;
import static com.google.common.truth.Truth.assertThat;
import static junit.framework.Assert.assertEquals;
import static junit.framework.Assert.assertFalse;
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 55
* @author mike nonemacher
*/
@SuppressWarnings("GuardedBy") // TODO(b/35466881): Fix or suppress.
class CacheTesting {
/**
* Poke into the Cache internals to simulate garbage collection of the value associated with the
* given key. This assumes that the associated entry is a WeakValueReference or a
* SoftValueReference (and not a LoadingValueReference), and throws an IllegalStateException if
Reported by PMD.
Line: 72
Preconditions.checkState(valueRef instanceof Reference);
Reference<V> ref = (Reference<V>) valueRef;
if (ref != null) {
ref.clear();
}
}
}
/**
Reported by PMD.
Line: 97
checkNotNull(cache);
checkNotNull(key);
LocalCache<K, V> map = toLocalCache(cache);
return map.getEntry(key);
}
/**
* Forces the segment containing the given {@code key} to expand (see {@link Segment#expand()}.
*/
Reported by PMD.
Line: 107
checkNotNull(cache);
checkNotNull(key);
LocalCache<K, V> map = toLocalCache(cache);
int hash = map.hash(key);
Segment<K, V> segment = map.segmentFor(hash);
segment.expand();
}
/**
Reported by PMD.
Line: 108
checkNotNull(key);
LocalCache<K, V> map = toLocalCache(cache);
int hash = map.hash(key);
Segment<K, V> segment = map.segmentFor(hash);
segment.expand();
}
/**
* Gets the {@link LocalCache} used by the given {@link Cache}, if any, or throws an
Reported by PMD.