Register DiskStorageCache for diskTrimmable slightly later in initialization process
Summary: If trimToXXX is called on the disk storage cache too early (before mResourceIndex is set), we can get NPEs. Let's move this down a little to avoid this.
@@ -173,15 +173,16 @@ public class DiskStorageCache implements FileCache, DiskTrimmable {
this.mCacheStats = new CacheStats();
- if (diskTrimmableRegistry != null) {
- diskTrimmableRegistry.registerDiskTrimmable(this);
- }
this.mClock = SystemClock.get();
mIndexPopulateAtStartupEnabled = indexPopulateAtStartupEnabled;
this.mResourceIndex = new HashSet<>();
+ if (diskTrimmableRegistry != null) {
+ diskTrimmableRegistry.registerDiskTrimmable(this);
+ }
+
if (mIndexPopulateAtStartupEnabled) {
mCountDownLatch = new CountDownLatch(1);
