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:
parent
a3b7241c1e
commit
96a266e7fd
1 changed files with 3 additions and 3 deletions
|
@ -282,7 +282,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
public String getValue(String name, String key) {
|
public String getValue(String name, String key) {
|
||||||
// Happens if this functions is called before class is fully initialized.
|
// Happens if this functions is called before class is fully initialized.
|
||||||
if (mConfig == null)
|
if (mConfig == null)
|
||||||
return null;
|
return "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Object value = mConfig.getJSONObject(name).get(key);
|
Object value = mConfig.getJSONObject(name).get(key);
|
||||||
|
@ -291,7 +291,7 @@ public class RestApi implements SyncthingService.OnWebGuiAvailableListener,
|
||||||
: value.toString();
|
: value.toString();
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
Log.w(TAG, "Failed to get value for " + key, 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;
|
return ret;
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
Log.w(TAG, "Failed to read devices", e);
|
Log.w(TAG, "Failed to read devices", e);
|
||||||
return null;
|
return new ArrayList<>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue