Bug 1280382 - Catch ClassCastException that may occur on return from generic method r=mcomella

MozReview-Commit-ID: BfiAMAEY1jY

--HG--
extra : rebase_source : d7fde4380e232a19880b896234d658f60a84965d
This commit is contained in:
Andrzej Hunt 2016-07-05 09:29:30 -07:00
parent 77ed70f397
commit 4b9284487d

View File

@ -713,11 +713,33 @@ public class ActivityHandler extends HandlerThread implements IActivityHandler {
}
private void readActivityState() {
activityState = Util.readObject(adjustConfig.context, ACTIVITY_STATE_FILENAME, ACTIVITY_STATE_NAME);
try {
/**
* Mozilla:
* readObject is a generic object, and can therefore return arbitrary generic objects
* that might not match the expected type. Therefore there will be an implicit cast
* here, which can fail. Therefore we have to add the catch (ClassCastException)
* Note: this has been fixed in upstream, we only need this for the version we are still shipping.
*/
activityState = Util.readObject(adjustConfig.context, ACTIVITY_STATE_FILENAME, ACTIVITY_STATE_NAME);
} catch (ClassCastException e) {
activityState = null;
}
}
private void readAttribution() {
attribution = Util.readObject(adjustConfig.context, ATTRIBUTION_FILENAME, ATTRIBUTION_NAME);
try {
/**
* Mozilla: (same as in readActivityState() )
* readObject is a generic object, and can therefore return arbitrary generic objects
* that might not match the expected type. Therefore there will be an implicit cast
* here, which can fail. Therefore we have to add the catch (ClassCastException)
* Note: this has been fixed in upstream, we only need this for the version we are still shipping.
*/
attribution = Util.readObject(adjustConfig.context, ATTRIBUTION_FILENAME, ATTRIBUTION_NAME);
} catch (ClassCastException e) {
activityState = null;
}
}
private void writeActivityState() {