mirror of
https://github.com/google/guava.git
synced 2026-10-28 08:35:50 +08:00
Use @GuardedBy more.
(prompted by cl/1002439657) RELNOTES=n/a PiperOrigin-RevId: 1008086513
This commit is contained in:
1 parent
0b93bfbf68
commit
9d36284ff4
18 files changed
+114
-2
No files matched your search
@@ -22,6 +22,7 @@ import static java.util.Collections.unmodifiableList;
|
||||
|
||||
import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -44,11 +45,14 @@ import org.jspecify.annotations.NullMarked;
|
||||
@GwtIncompatible
|
||||
public final class FeatureUtil {
|
||||
/** A cache of annotated objects (typically a Class or Method) to its set of annotations. */
|
||||
@GuardedBy("annotationCache")
|
||||
private static final Map<AnnotatedElement, List<Annotation>> annotationCache = new HashMap<>();
|
||||
|
||||
@GuardedBy("classTesterRequirementsCache")
|
||||
private static final Map<Class<?>, TesterRequirements> classTesterRequirementsCache =
|
||||
new HashMap<>();
|
||||
|
||||
@GuardedBy("methodTesterRequirementsCache")
|
||||
private static final Map<Method, TesterRequirements> methodTesterRequirementsCache =
|
||||
new HashMap<>();
|
||||
|
||||
|
||||
+2
@@ -356,6 +356,8 @@ public class ExecutionListBenchmark {
|
||||
private static final class OldExecutionList {
|
||||
static final Logger log = Logger.getLogger(OldExecutionList.class.getName());
|
||||
final Queue<OldExecutionList.RunnableExecutorPair> runnables = new LinkedList<>();
|
||||
|
||||
@GuardedBy("runnables")
|
||||
boolean executed = false;
|
||||
|
||||
void add(Runnable runnable, Executor executor) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.common.annotations.J2ktIncompatible;
|
||||
import com.google.common.cache.LocalCache.Strength;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.lang.ref.WeakReference;
|
||||
import junit.framework.TestCase;
|
||||
import org.jspecify.annotations.NullUnmarked;
|
||||
@@ -124,6 +125,8 @@ public class CacheReferencesTest extends TestCase {
|
||||
// a strong reference to that value.
|
||||
private static final class Key {
|
||||
private final int value;
|
||||
|
||||
@GuardedBy("this")
|
||||
private @Nullable WeakReference<String> toString;
|
||||
|
||||
Key(int value) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertThrows;
|
||||
|
||||
import com.google.common.annotations.GwtCompatible;
|
||||
import com.google.common.util.concurrent.TestExceptions.SomeError;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.Executor;
|
||||
import junit.framework.TestCase;
|
||||
@@ -67,6 +68,8 @@ public class FutureCallbackTest extends TestCase {
|
||||
FutureCallback<String> callback =
|
||||
new FutureCallback<String>() {
|
||||
private final Object monitor = new Object();
|
||||
|
||||
@GuardedBy("monitor")
|
||||
private boolean called = false;
|
||||
|
||||
@Override
|
||||
@@ -181,7 +184,10 @@ public class FutureCallbackTest extends TestCase {
|
||||
private static final class MockCallback implements FutureCallback<String> {
|
||||
@Nullable private String value = null;
|
||||
@Nullable private Throwable failure = null;
|
||||
|
||||
@GuardedBy("monitor")
|
||||
private boolean wasCalled = false;
|
||||
|
||||
private final Object monitor = new Object();
|
||||
|
||||
MockCallback(String expectedValue) {
|
||||
|
||||
@@ -57,6 +57,7 @@ import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.testing.ClassSanityTester;
|
||||
import com.google.common.util.concurrent.MoreExecutors.Application;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.lang.Thread.State;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -633,6 +634,7 @@ public class MoreExecutorsTest extends TestCase {
|
||||
|
||||
@J2ktIncompatible
|
||||
private static class TestApplication extends Application {
|
||||
@GuardedBy("this")
|
||||
private final List<Thread> hooks = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.google.common.annotations.GwtCompatible;
|
||||
import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.common.annotations.J2ktIncompatible;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import com.google.j2objc.annotations.RetainedWith;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
@@ -446,7 +447,10 @@ final class Synchronized {
|
||||
|
||||
static final class SynchronizedMultiset<E extends @Nullable Object>
|
||||
extends SynchronizedCollection<E> implements Multiset<E> {
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<E> elementSet;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<Entry<E>> entrySet;
|
||||
|
||||
SynchronizedMultiset(Multiset<E> delegate, @Nullable Object mutex) {
|
||||
@@ -543,10 +547,19 @@ final class Synchronized {
|
||||
|
||||
private static class SynchronizedMultimap<K extends @Nullable Object, V extends @Nullable Object>
|
||||
extends SynchronizedObject implements Multimap<K, V> {
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<K> keySet;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Collection<V> valuesCollection;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Collection<Map.Entry<K, V>> entries;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Map<K, Collection<V>> asMap;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Multiset<K> keys;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -777,6 +790,7 @@ final class Synchronized {
|
||||
private static class SynchronizedSetMultimap<
|
||||
K extends @Nullable Object, V extends @Nullable Object>
|
||||
extends SynchronizedMultimap<K, V> implements SetMultimap<K, V> {
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<Map.Entry<K, V>> entrySet;
|
||||
|
||||
SynchronizedSetMultimap(SetMultimap<K, V> delegate, @Nullable Object mutex) {
|
||||
@@ -1005,8 +1019,13 @@ final class Synchronized {
|
||||
|
||||
private static class SynchronizedMap<K extends @Nullable Object, V extends @Nullable Object>
|
||||
extends SynchronizedObject implements Map<K, V> {
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<K> keySet;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Collection<V> values;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<Entry<K, V>> entrySet;
|
||||
|
||||
SynchronizedMap(Map<K, V> delegate, @Nullable Object mutex) {
|
||||
@@ -1204,8 +1223,12 @@ final class Synchronized {
|
||||
|
||||
static final class SynchronizedBiMap<K extends @Nullable Object, V extends @Nullable Object>
|
||||
extends SynchronizedMap<K, V> implements BiMap<K, V> {
|
||||
@GuardedBy("mutex")
|
||||
private transient @Nullable Set<V> valueSet;
|
||||
@RetainedWith private transient @Nullable BiMap<V, K> inverse;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
@RetainedWith
|
||||
private transient @Nullable BiMap<V, K> inverse;
|
||||
|
||||
private SynchronizedBiMap(
|
||||
BiMap<K, V> delegate, @Nullable Object mutex, @Nullable BiMap<V, K> inverse) {
|
||||
@@ -1251,7 +1274,10 @@ final class Synchronized {
|
||||
private static final class SynchronizedAsMap<
|
||||
K extends @Nullable Object, V extends @Nullable Object>
|
||||
extends SynchronizedMap<K, Collection<V>> {
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<Entry<K, Collection<V>>> asMapEntrySet;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Collection<Collection<V>> asMapValues;
|
||||
|
||||
SynchronizedAsMap(Map<K, Collection<V>> delegate, @Nullable Object mutex) {
|
||||
@@ -1342,6 +1368,7 @@ final class Synchronized {
|
||||
return delegate().descendingIterator(); // manually synchronized
|
||||
}
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable NavigableSet<E> descendingSet;
|
||||
|
||||
@Override
|
||||
@@ -1484,6 +1511,7 @@ final class Synchronized {
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable NavigableSet<K> descendingKeySet;
|
||||
|
||||
@Override
|
||||
@@ -1496,6 +1524,7 @@ final class Synchronized {
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable NavigableMap<K, V> descendingMap;
|
||||
|
||||
@Override
|
||||
@@ -1581,6 +1610,7 @@ final class Synchronized {
|
||||
return navigableKeySet();
|
||||
}
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable NavigableSet<K> navigableKeySet;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.common.annotations.J2ktIncompatible;
|
||||
import com.google.common.math.IntMath;
|
||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInput;
|
||||
@@ -714,6 +715,8 @@ public final class ByteStreams {
|
||||
@J2ktIncompatible
|
||||
private static final class LimitedInputStream extends FilterInputStream {
|
||||
private long left;
|
||||
|
||||
@GuardedBy("this")
|
||||
private long mark = -1;
|
||||
|
||||
LimitedInputStream(InputStream in, long limit) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.common.annotations.J2ktIncompatible;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.CharBuffer;
|
||||
@@ -40,6 +41,8 @@ final class CharSequenceReader extends Reader {
|
||||
|
||||
private @Nullable CharSequence seq;
|
||||
private int pos;
|
||||
|
||||
@GuardedBy("this")
|
||||
private int mark;
|
||||
|
||||
/** Creates a new reader wrapping the given character sequence. */
|
||||
|
||||
@@ -19,6 +19,7 @@ import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.common.annotations.J2ktIncompatible;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -34,6 +35,8 @@ import java.io.InputStream;
|
||||
public final class CountingInputStream extends FilterInputStream {
|
||||
|
||||
private long count;
|
||||
|
||||
@GuardedBy("this")
|
||||
private long mark = -1;
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,6 +22,7 @@ import static java.util.Collections.unmodifiableList;
|
||||
|
||||
import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.AnnotatedElement;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -44,11 +45,14 @@ import org.jspecify.annotations.NullMarked;
|
||||
@GwtIncompatible
|
||||
public final class FeatureUtil {
|
||||
/** A cache of annotated objects (typically a Class or Method) to its set of annotations. */
|
||||
@GuardedBy("annotationCache")
|
||||
private static final Map<AnnotatedElement, List<Annotation>> annotationCache = new HashMap<>();
|
||||
|
||||
@GuardedBy("classTesterRequirementsCache")
|
||||
private static final Map<Class<?>, TesterRequirements> classTesterRequirementsCache =
|
||||
new HashMap<>();
|
||||
|
||||
@GuardedBy("methodTesterRequirementsCache")
|
||||
private static final Map<Method, TesterRequirements> methodTesterRequirementsCache =
|
||||
new HashMap<>();
|
||||
|
||||
|
||||
@@ -356,6 +356,8 @@ public class ExecutionListBenchmark {
|
||||
private static final class OldExecutionList {
|
||||
static final Logger log = Logger.getLogger(OldExecutionList.class.getName());
|
||||
final Queue<OldExecutionList.RunnableExecutorPair> runnables = new LinkedList<>();
|
||||
|
||||
@GuardedBy("runnables")
|
||||
boolean executed = false;
|
||||
|
||||
void add(Runnable runnable, Executor executor) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.common.annotations.J2ktIncompatible;
|
||||
import com.google.common.cache.LocalCache.Strength;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.lang.ref.WeakReference;
|
||||
import junit.framework.TestCase;
|
||||
import org.jspecify.annotations.NullUnmarked;
|
||||
@@ -124,6 +125,8 @@ public class CacheReferencesTest extends TestCase {
|
||||
// a strong reference to that value.
|
||||
private static final class Key {
|
||||
private final int value;
|
||||
|
||||
@GuardedBy("this")
|
||||
private @Nullable WeakReference<String> toString;
|
||||
|
||||
Key(int value) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import static org.junit.Assert.assertThrows;
|
||||
|
||||
import com.google.common.annotations.GwtCompatible;
|
||||
import com.google.common.util.concurrent.TestExceptions.SomeError;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.util.concurrent.CancellationException;
|
||||
import java.util.concurrent.Executor;
|
||||
import junit.framework.TestCase;
|
||||
@@ -67,6 +68,8 @@ public class FutureCallbackTest extends TestCase {
|
||||
FutureCallback<String> callback =
|
||||
new FutureCallback<String>() {
|
||||
private final Object monitor = new Object();
|
||||
|
||||
@GuardedBy("monitor")
|
||||
private boolean called = false;
|
||||
|
||||
@Override
|
||||
@@ -181,7 +184,10 @@ public class FutureCallbackTest extends TestCase {
|
||||
private static final class MockCallback implements FutureCallback<String> {
|
||||
@Nullable private String value = null;
|
||||
@Nullable private Throwable failure = null;
|
||||
|
||||
@GuardedBy("monitor")
|
||||
private boolean wasCalled = false;
|
||||
|
||||
private final Object monitor = new Object();
|
||||
|
||||
MockCallback(String expectedValue) {
|
||||
|
||||
@@ -57,6 +57,7 @@ import com.google.common.base.Suppliers;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.common.testing.ClassSanityTester;
|
||||
import com.google.common.util.concurrent.MoreExecutors.Application;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.lang.Thread.State;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -633,6 +634,7 @@ public class MoreExecutorsTest extends TestCase {
|
||||
|
||||
@J2ktIncompatible
|
||||
private static class TestApplication extends Application {
|
||||
@GuardedBy("this")
|
||||
private final List<Thread> hooks = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.google.common.annotations.GwtCompatible;
|
||||
import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.common.annotations.J2ktIncompatible;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import com.google.j2objc.annotations.RetainedWith;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectOutputStream;
|
||||
@@ -504,7 +505,10 @@ final class Synchronized {
|
||||
|
||||
static final class SynchronizedMultiset<E extends @Nullable Object>
|
||||
extends SynchronizedCollection<E> implements Multiset<E> {
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<E> elementSet;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<Entry<E>> entrySet;
|
||||
|
||||
SynchronizedMultiset(Multiset<E> delegate, @Nullable Object mutex) {
|
||||
@@ -601,10 +605,19 @@ final class Synchronized {
|
||||
|
||||
private static class SynchronizedMultimap<K extends @Nullable Object, V extends @Nullable Object>
|
||||
extends SynchronizedObject implements Multimap<K, V> {
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<K> keySet;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Collection<V> valuesCollection;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Collection<Map.Entry<K, V>> entries;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Map<K, Collection<V>> asMap;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Multiset<K> keys;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@@ -842,6 +855,7 @@ final class Synchronized {
|
||||
private static class SynchronizedSetMultimap<
|
||||
K extends @Nullable Object, V extends @Nullable Object>
|
||||
extends SynchronizedMultimap<K, V> implements SetMultimap<K, V> {
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<Map.Entry<K, V>> entrySet;
|
||||
|
||||
SynchronizedSetMultimap(SetMultimap<K, V> delegate, @Nullable Object mutex) {
|
||||
@@ -1070,8 +1084,13 @@ final class Synchronized {
|
||||
|
||||
private static class SynchronizedMap<K extends @Nullable Object, V extends @Nullable Object>
|
||||
extends SynchronizedObject implements Map<K, V> {
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<K> keySet;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Collection<V> values;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<Entry<K, V>> entrySet;
|
||||
|
||||
SynchronizedMap(Map<K, V> delegate, @Nullable Object mutex) {
|
||||
@@ -1355,8 +1374,12 @@ final class Synchronized {
|
||||
|
||||
static final class SynchronizedBiMap<K extends @Nullable Object, V extends @Nullable Object>
|
||||
extends SynchronizedMap<K, V> implements BiMap<K, V> {
|
||||
@GuardedBy("mutex")
|
||||
private transient @Nullable Set<V> valueSet;
|
||||
@RetainedWith private transient @Nullable BiMap<V, K> inverse;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
@RetainedWith
|
||||
private transient @Nullable BiMap<V, K> inverse;
|
||||
|
||||
private SynchronizedBiMap(
|
||||
BiMap<K, V> delegate, @Nullable Object mutex, @Nullable BiMap<V, K> inverse) {
|
||||
@@ -1402,7 +1425,10 @@ final class Synchronized {
|
||||
private static final class SynchronizedAsMap<
|
||||
K extends @Nullable Object, V extends @Nullable Object>
|
||||
extends SynchronizedMap<K, Collection<V>> {
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Set<Entry<K, Collection<V>>> asMapEntrySet;
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable Collection<Collection<V>> asMapValues;
|
||||
|
||||
SynchronizedAsMap(Map<K, Collection<V>> delegate, @Nullable Object mutex) {
|
||||
@@ -1493,6 +1519,7 @@ final class Synchronized {
|
||||
return delegate().descendingIterator(); // manually synchronized
|
||||
}
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable NavigableSet<E> descendingSet;
|
||||
|
||||
@Override
|
||||
@@ -1635,6 +1662,7 @@ final class Synchronized {
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable NavigableSet<K> descendingKeySet;
|
||||
|
||||
@Override
|
||||
@@ -1647,6 +1675,7 @@ final class Synchronized {
|
||||
}
|
||||
}
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable NavigableMap<K, V> descendingMap;
|
||||
|
||||
@Override
|
||||
@@ -1732,6 +1761,7 @@ final class Synchronized {
|
||||
return navigableKeySet();
|
||||
}
|
||||
|
||||
@GuardedBy("mutex")
|
||||
transient @Nullable NavigableSet<K> navigableKeySet;
|
||||
|
||||
@Override
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.common.annotations.J2ktIncompatible;
|
||||
import com.google.common.math.IntMath;
|
||||
import com.google.errorprone.annotations.CanIgnoreReturnValue;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataInput;
|
||||
@@ -714,6 +715,8 @@ public final class ByteStreams {
|
||||
@J2ktIncompatible
|
||||
private static final class LimitedInputStream extends FilterInputStream {
|
||||
private long left;
|
||||
|
||||
@GuardedBy("this")
|
||||
private long mark = -1;
|
||||
|
||||
LimitedInputStream(InputStream in, long limit) {
|
||||
|
||||
@@ -22,6 +22,7 @@ import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.common.annotations.J2ktIncompatible;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
import java.nio.CharBuffer;
|
||||
@@ -40,6 +41,8 @@ final class CharSequenceReader extends Reader {
|
||||
|
||||
private @Nullable CharSequence seq;
|
||||
private int pos;
|
||||
|
||||
@GuardedBy("this")
|
||||
private int mark;
|
||||
|
||||
/** Creates a new reader wrapping the given character sequence. */
|
||||
|
||||
@@ -19,6 +19,7 @@ import static java.util.Objects.requireNonNull;
|
||||
|
||||
import com.google.common.annotations.GwtIncompatible;
|
||||
import com.google.common.annotations.J2ktIncompatible;
|
||||
import com.google.errorprone.annotations.concurrent.GuardedBy;
|
||||
import java.io.FilterInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -34,6 +35,8 @@ import java.io.InputStream;
|
||||
public final class CountingInputStream extends FilterInputStream {
|
||||
|
||||
private long count;
|
||||
|
||||
@GuardedBy("this")
|
||||
private long mark = -1;
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user