Commit b69041be by eguven Committed by Andrew Lewis

Prevent NullPointerException exceptions in SimpleCache initialization

This is a temporary fix to prevent NullPointerException exceptions.
Though writing to cache will still fail if the cache folder isn't a real
folder.

There are a few thing we can try:
* The listing might be failing because the cache folder is just created.
We can wait and try again.
* If the cache folder is a regular file, we can try deleting and creating
a folder with the same name.

PiperOrigin-RevId: 234121925
parent 8982da4b
...@@ -582,6 +582,7 @@ public final class SimpleCache implements Cache { ...@@ -582,6 +582,7 @@ public final class SimpleCache implements Cache {
* @throws IOException If there is an error loading or generating the UID. * @throws IOException If there is an error loading or generating the UID.
*/ */
private static long loadUid(File directory, File[] files) throws IOException { private static long loadUid(File directory, File[] files) throws IOException {
if (files != null) {
for (File file : files) { for (File file : files) {
String fileName = file.getName(); String fileName = file.getName();
if (fileName.endsWith(UID_FILE_SUFFIX)) { if (fileName.endsWith(UID_FILE_SUFFIX)) {
...@@ -594,6 +595,7 @@ public final class SimpleCache implements Cache { ...@@ -594,6 +595,7 @@ public final class SimpleCache implements Cache {
} }
} }
} }
}
return createUid(directory); return createUid(directory);
} }
......
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