Bug 1369892 - Silence findbugs dodgy casting warning r=nalexander
authorGrigory Kruglov <gkruglov@mozilla.com>
Fri, 02 Jun 2017 18:15:32 -0400
changeset 410242 72ab73cbc5c7d6f18d55a855103e48d7a8bb7eae
parent 410241 4f5b93b0571a23c8314233534b06a1aeb476fb1e
child 410243 60b41398d6c261f0906baa51014f6461a21d298b
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnalexander
bugs1369892
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1369892 - Silence findbugs dodgy casting warning r=nalexander Strangely enough, this patch seems to appease findbugs. While dodgy indeed, I think this casting is acceptable in this case since we control both sides of the equation (sender & receiver of telemetry), but can't easily do away with casting. MozReview-Commit-ID: FBTkRqKPtxt
mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetrySyncPingBuilder.java
--- a/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetrySyncPingBuilder.java
+++ b/mobile/android/base/java/org/mozilla/gecko/telemetry/pingbuilders/TelemetrySyncPingBuilder.java
@@ -126,17 +126,17 @@ public class TelemetrySyncPingBuilder ex
 
         if (devicesJSON.size() > 0) {
             payload.put("devices", devicesJSON);
         }
         return this;
     }
 
     public TelemetrySyncPingBuilder setError(@NonNull Serializable error) {
-        payload.put("failureReason", (ExtendedJSONObject) error);
+        payload.put("failureReason", castErrorObject(error));
         return this;
     }
 
     public TelemetrySyncPingBuilder setTook(long took) {
         payload.put("took", took);
         return this;
     }
 
@@ -154,9 +154,13 @@ public class TelemetrySyncPingBuilder ex
     /**
      * We broadcast this data via LocalBroadcastManager and control both sides of this code, so it
      * is acceptable to do an unchecked cast.
      */
     @SuppressWarnings("unchecked")
     private static HashMap<String, TelemetryStageCollector> castSyncData(final Serializable data) {
         return (HashMap<String, TelemetryStageCollector>) data;
     }
+
+    private static ExtendedJSONObject castErrorObject(final Serializable error) {
+        return (ExtendedJSONObject) error;
+    }
 }