Skip to content

Commit 650fe60

Browse files
committed
Adds a null check on the settingObject to prevent a crash when the response is not the expected
1 parent f6a8606 commit 650fe60

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

WordPress/src/main/java/org/wordpress/android/ui/prefs/WPComSiteSettings.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,10 @@ private JSONObject serializeWpComParamsToJSONObject() throws JSONException {
908908
private void deserializeJetpackRestResponse(SiteModel site, JSONObject response) {
909909
if (site == null || response == null) return;
910910
JSONObject settingsObject = response.optJSONObject("settings");
911+
if (settingsObject == null) {
912+
AppLog.e(AppLog.T.API, "Error: response doesn't contain settings object");
913+
return;
914+
}
911915
mRemoteJpSettings.emailNotifications = settingsObject.optBoolean(JP_MONITOR_EMAIL_NOTES_KEY, false);
912916
mRemoteJpSettings.wpNotifications = settingsObject.optBoolean(JP_MONITOR_WP_NOTES_KEY, false);
913917
}

0 commit comments

Comments
 (0)