1
0
Fork 0
mirror of https://github.com/syncthing/syncthing-android.git synced 2024-11-30 00:01:19 +00:00

Fixed NPE when JSON parsing fails.

This commit is contained in:
Felix Ableitner 2015-03-14 21:19:27 +01:00
parent a3b7241c1e
commit 96a266e7fd

View file

@ -282,7 +282,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
public String getValue(String name, String key) {
// Happens if this functions is called before class is fully initialized.
if (mConfig == null)
return null;
return "";
try {
Object value = mConfig.getJSONObject(name).get(key);
@ -291,7 +291,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
: value.toString();
} catch (JSONException e) {
Log.w(TAG, "Failed to get value for " + key, e);
return null;
return "";
}
}
@ -416,7 +416,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
return ret;
} catch (JSONException e) {
Log.w(TAG, "Failed to read devices", e);
return null;
return new ArrayList<>();
}
}