Bug 1314835: Add more debug information to TelemetryPingStore r=sebastian a=jcristau
authorJulian_Chu <walkingice0204@gmail.com>
Tue, 15 Nov 2016 14:35:59 +0800
changeset 352845 2ac543baa4920166fc214dd70df9058486e7cdf7
parent 352844 23f379faaef5c4114a4c07f5f0aa0039e7c96096
child 352846 bf7877a40fe66b43c031b19aff4920418c1dbd01
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssebastian, jcristau
bugs1314835
milestone52.0a2
Bug 1314835: Add more debug information to TelemetryPingStore r=sebastian a=jcristau 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