Bug 1314835: Add more debug information to TelemetryPingStore r=sebastian
authorJulian_Chu <walkingice0204@gmail.com>
Tue, 15 Nov 2016 14:35:59 +0800
changeset 324937 4c969c7c1c2221e2e9c3da63b1153ddbaf1378f5
parent 324936 adf193b5d6c9ce92b05a9370e8b4a5699bae537a
child 324938 1c6c9a6c9b16991dc4605aef989f1ae0c8ff8820
push id24
push usermaklebus@msu.edu
push dateTue, 20 Dec 2016 03:11:33 +0000
reviewerssebastian
bugs1314835
milestone53.0a1
Bug 1314835: Add more debug information to TelemetryPingStore r=sebastian 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
mobile/android/base/java/org/mozilla/gecko/telemetry/stores/TelemetryJSONFilePingStore.java
--- 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