Make removal of non-existent cache span a no-op

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=155413733
This commit is contained in:
tasnimsunny 2017-05-08 12:46:09 -07:00 committed by Oliver Woodman
parent 812068a208
commit b299718036

View File

@ -286,7 +286,9 @@ public final class SimpleCache implements Cache {
private void removeSpan(CacheSpan span, boolean removeEmptyCachedContent) throws CacheException { private void removeSpan(CacheSpan span, boolean removeEmptyCachedContent) throws CacheException {
CachedContent cachedContent = index.get(span.key); CachedContent cachedContent = index.get(span.key);
Assertions.checkState(cachedContent.removeSpan(span)); if (cachedContent == null || !cachedContent.removeSpan(span)) {
return;
}
totalSpace -= span.length; totalSpace -= span.length;
if (removeEmptyCachedContent && cachedContent.isEmpty()) { if (removeEmptyCachedContent && cachedContent.isEmpty()) {
index.removeEmpty(cachedContent.key); index.removeEmpty(cachedContent.key);