Bug 1314835: Add more debug information to TelemetryPingStore
So far still cannot find the reason of causing exception. To add more
debug information to make sure it is not permssion problem.
MozReview-Commit-ID: 7hhU7Et64Qs
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryJSONFilePingStore.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryJSONFilePingStore.java
@@ -190,17 +190,23 @@ public class TelemetryJSONFilePingStore
Log.w(LOGTAG, "Unexpected empty file: " + file.getName() + ". Ignoring");
return null;
}
final FileInputStream inputStream;
try {
inputStream = new FileInputStream(file);
} catch (final FileNotFoundException e) {
- throw new IllegalStateException("Expected file to exist");
+ // permission problem might also cause same exception. To get more debug information.
+ String fileInfo = String.format("existence: %b, can write: %b, size: %l.",
+ file.exists(), file.canWrite(), file.length());
+ String msg = String.format(
+ "Expected file to exist but got exception in thread: %s. File info - %s",
+ Thread.currentThread().getName(), fileInfo);
+ throw new IllegalStateException(msg);
}
final JSONObject obj;
try {
// Potential optimization: re-use the same buffer for reading from files.
obj = lockAndReadFileAndCloseStream(inputStream, (int) file.length());
} catch (final IOException | JSONException e) {
// We couldn't read this file so let's just skip it. These potentially