Bug 1314835: Add more debug information to TelemetryPingStore draft
authorJulian_Chu <walkingice0204@gmail.com>
Tue, 15 Nov 2016 14:35:59 +0800
changeset 446325 14c400a331cb16ed22641df55223bb0129b7e190
parent 444478 05328d3102efd4d5fc0696489734d7771d24459f
child 538760 a432c669e23680ed1cfe43af93d664a46712e8ee
push id37760
push userbmo:walkingice0204@gmail.com
push dateThu, 01 Dec 2016 08:24:20 +0000
bugs1314835
milestone53.0a1
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
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