Commit 6b03ce8f by olly Committed by Oliver Woodman

Remove SimpleCache hacks that are no longer used

PiperOrigin-RevId: 281049383
parent 09df3a01
...@@ -61,9 +61,6 @@ public final class SimpleCache implements Cache { ...@@ -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;
...@@ -86,33 +83,6 @@ public final class SimpleCache implements Cache { ...@@ -86,33 +83,6 @@ public final class SimpleCache implements Cache {
} }
/** /**
* 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.
* *
* @param cacheDir The cache directory. * @param cacheDir The cache directory.
...@@ -304,7 +274,7 @@ public final class SimpleCache implements Cache { ...@@ -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 { ...@@ -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());
} }
}
} }
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