Check for user ID file before trying to read it
The user ID file will be missing if no user ID was set, so check
if it exists before trying to read from it to avoid unnecessary
error logging.
Fixes one of the prevalent issues in
@@ -305,11 +305,14 @@ public class CrashlyticsReportPersistence {
}
String userId = null;
+ final File userIdFile = new File(sessionDirectory, USER_FILE_NAME);
+ if (userIdFile.isFile()) {
try {
- userId = readTextFile(new File(sessionDirectory, USER_FILE_NAME));
+ userId = readTextFile(userIdFile);
} catch (IOException e) {
Logger.getLogger().d("Could not read user ID file in " + sessionDirectory.getName(), e);
}
+ }
final File reportFile = new File(sessionDirectory, REPORT_FILE_NAME);
final File outputDirectory = isHighPriorityReport ? priorityReportsDirectory : reportsDirectory;
