Remove SimpleCache hacks that are no longer used

PiperOrigin-RevId: 281049383
This commit is contained in:
olly 2019-11-18 13:38:06 +00:00 committed by Oliver Woodman
parent 7f2827077c
commit 3e17080c02

View File

@ -61,9 +61,6 @@ public final class SimpleCache implements Cache {
private static final HashSet<File> lockedCacheDirs = new HashSet<>(); private static final HashSet<File> lockedCacheDirs = new HashSet<>();
private static boolean cacheFolderLockingDisabled;
private static boolean cacheInitializationExceptionsDisabled;
private final File cacheDir; private final File cacheDir;
private final CacheEvictor evictor; private final CacheEvictor evictor;
private final CachedContentIndex contentIndex; private final CachedContentIndex contentIndex;
@ -85,33 +82,6 @@ public final class SimpleCache implements Cache {
return lockedCacheDirs.contains(cacheFolder.getAbsoluteFile()); return lockedCacheDirs.contains(cacheFolder.getAbsoluteFile());
} }
/**
* Disables locking the cache folders which {@link SimpleCache} instances are using and releases
* any previous lock.
*
* <p>The locking prevents multiple {@link SimpleCache} instances from being created for the same
* folder. Disabling it may cause the cache data to be corrupted. Use at your own risk.
*
* @deprecated Don't create multiple {@link SimpleCache} instances for the same cache folder. If
* you need to create another instance, make sure you call {@link #release()} on the previous
* instance.
*/
@Deprecated
public static synchronized void disableCacheFolderLocking() {
cacheFolderLockingDisabled = true;
lockedCacheDirs.clear();
}
/**
* Disables throwing of cache initialization exceptions.
*
* @deprecated Don't use this. Provided for problematic upgrade cases only.
*/
@Deprecated
public static void disableCacheInitializationExceptions() {
cacheInitializationExceptionsDisabled = true;
}
/** /**
* Deletes all content belonging to a cache instance. * Deletes all content belonging to a cache instance.
* *
@ -304,7 +274,7 @@ public final class SimpleCache implements Cache {
* @throws CacheException If an error occurred during initialization. * @throws CacheException If an error occurred during initialization.
*/ */
public synchronized void checkInitialization() throws CacheException { public synchronized void checkInitialization() throws CacheException {
if (!cacheInitializationExceptionsDisabled && initializationException != null) { if (initializationException != null) {
throw initializationException; throw initializationException;
} }
} }
@ -828,15 +798,10 @@ public final class SimpleCache implements Cache {
} }
private static synchronized boolean lockFolder(File cacheDir) { private static synchronized boolean lockFolder(File cacheDir) {
if (cacheFolderLockingDisabled) {
return true;
}
return lockedCacheDirs.add(cacheDir.getAbsoluteFile()); return lockedCacheDirs.add(cacheDir.getAbsoluteFile());
} }
private static synchronized void unlockFolder(File cacheDir) { private static synchronized void unlockFolder(File cacheDir) {
if (!cacheFolderLockingDisabled) { lockedCacheDirs.remove(cacheDir.getAbsoluteFile());
lockedCacheDirs.remove(cacheDir.getAbsoluteFile());
}
} }
} }