Commit feb4cce2 by bachinger Committed by Oliver Woodman

Enable nullness test for CachedContent/CachedContentIndex

PiperOrigin-RevId: 328551668
parent 94cff6ba
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
package com.google.android.exoplayer2.upstream.cache; package com.google.android.exoplayer2.upstream.cache;
import static com.google.android.exoplayer2.util.Assertions.checkArgument; import static com.google.android.exoplayer2.util.Assertions.checkArgument;
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
import static com.google.android.exoplayer2.util.Assertions.checkState; import static com.google.android.exoplayer2.util.Assertions.checkState;
import static java.lang.Math.max; import static java.lang.Math.max;
import static java.lang.Math.min; import static java.lang.Math.min;
...@@ -219,9 +220,9 @@ import java.util.TreeSet; ...@@ -219,9 +220,9 @@ import java.util.TreeSet;
public SimpleCacheSpan setLastTouchTimestamp( public SimpleCacheSpan setLastTouchTimestamp(
SimpleCacheSpan cacheSpan, long lastTouchTimestamp, boolean updateFile) { SimpleCacheSpan cacheSpan, long lastTouchTimestamp, boolean updateFile) {
checkState(cachedSpans.remove(cacheSpan)); checkState(cachedSpans.remove(cacheSpan));
File file = cacheSpan.file; File file = checkNotNull(cacheSpan.file);
if (updateFile) { if (updateFile) {
File directory = file.getParentFile(); File directory = checkNotNull(file.getParentFile());
long position = cacheSpan.position; long position = cacheSpan.position;
File newFile = SimpleCacheSpan.getCacheFile(directory, id, position, lastTouchTimestamp); File newFile = SimpleCacheSpan.getCacheFile(directory, id, position, lastTouchTimestamp);
if (file.renameTo(newFile)) { if (file.renameTo(newFile)) {
...@@ -244,7 +245,9 @@ import java.util.TreeSet; ...@@ -244,7 +245,9 @@ import java.util.TreeSet;
/** Removes the given span from cache. */ /** Removes the given span from cache. */
public boolean removeSpan(CacheSpan span) { public boolean removeSpan(CacheSpan span) {
if (cachedSpans.remove(span)) { if (cachedSpans.remove(span)) {
if (span.file != null) {
span.file.delete(); span.file.delete();
}
return true; return true;
} }
return false; return false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment