Don't put loading results to system cache if exceptions happened.
Test: Manual smoke tests. Automatic tests pass.
Bug: 34405495
Change-Id: If8ce36ce38eef840655be84438856ca12187c393
(cherry picked from commit 51b8ca37126b63cb5e4c9fe4a8f092c104290486)
diff --git a/src/com/android/documentsui/roots/RootsCache.java b/src/com/android/documentsui/roots/RootsCache.java
index ad91228..3d367a6 100644
--- a/src/com/android/documentsui/roots/RootsCache.java
+++ b/src/com/android/documentsui/roots/RootsCache.java
@@ -260,7 +260,11 @@
roots.add(root);
}
} catch (Exception e) {
- Log.w(TAG, "Failed to load some roots from " + authority + ": " + e);
+ Log.w(TAG, "Failed to load some roots from " + authority, e);
+ // We didn't load every root from the provider. Don't put it to
+ // system cache so that we'll try loading them again next time even
+ // if forceRefresh is false.
+ return roots;
} finally {
IoUtils.closeQuietly(cursor);
ContentProviderClient.releaseQuietly(client);