Add nullness annotations to `SimpleCache`

#fixit

PiperOrigin-RevId: 558783228
This commit is contained in:
rohks 2023-08-21 15:32:24 +01:00 committed by Julia Bibik
parent 4fad529433
commit 91764baa90
1 changed files with 5 additions and 4 deletions

View File

@ -652,7 +652,8 @@ public final class SimpleCache implements Cache {
updateFile = true;
}
SimpleCacheSpan newSpan =
contentIndex.get(key).setLastTouchTimestamp(span, lastTouchTimestamp, updateFile);
Assertions.checkNotNull(contentIndex.get(key))
.setLastTouchTimestamp(span, lastTouchTimestamp, updateFile);
notifySpanTouched(span, newSpan);
return newSpan;
}
@ -673,7 +674,7 @@ public final class SimpleCache implements Cache {
}
while (true) {
SimpleCacheSpan span = cachedContent.getSpan(position, length);
if (span.isCached && span.file.length() != span.length) {
if (span.isCached && Assertions.checkNotNull(span.file).length() != span.length) {
// The file has been modified or deleted underneath us. It's likely that other files will
// have been modified too, so scan the whole in-memory representation.
removeStaleSpans();
@ -701,7 +702,7 @@ public final class SimpleCache implements Cache {
}
totalSpace -= span.length;
if (fileIndex != null) {
String fileName = span.file.getName();
String fileName = Assertions.checkNotNull(span.file).getName();
try {
fileIndex.remove(fileName);
} catch (IOException e) {
@ -722,7 +723,7 @@ public final class SimpleCache implements Cache {
ArrayList<CacheSpan> spansToBeRemoved = new ArrayList<>();
for (CachedContent cachedContent : contentIndex.getAll()) {
for (CacheSpan span : cachedContent.getSpans()) {
if (span.file.length() != span.length) {
if (Assertions.checkNotNull(span.file).length() != span.length) {
spansToBeRemoved.add(span);
}
}