catch possible nullpointerexception if returned json does not contain our currency

This commit is contained in:
elroy 2017-07-01 22:30:06 +02:00
parent 03b7acb198
commit 34d6430c1a
1 changed files with 2 additions and 2 deletions

View File

@ -69,7 +69,7 @@ public class GunbotProxyController {
JsonElement jelement = new JsonParser().parse(result); JsonElement jelement = new JsonParser().parse(result);
JsonObject jobject = jelement.getAsJsonObject(); JsonObject jobject = jelement.getAsJsonObject();
JsonArray jarray = jobject.getAsJsonArray(currencyPair); JsonArray jarray = jobject.getAsJsonArray(currencyPair);
return jarray.toString(); return jarray != null ? jarray.toString() : "[]";
} }
@RequestMapping(value = "/tradingApi/**", params = "command=returnTradeHistory") @RequestMapping(value = "/tradingApi/**", params = "command=returnTradeHistory")
@ -82,7 +82,7 @@ public class GunbotProxyController {
JsonElement jelement = new JsonParser().parse(result); JsonElement jelement = new JsonParser().parse(result);
JsonObject jobject = jelement.getAsJsonObject(); JsonObject jobject = jelement.getAsJsonObject();
JsonArray jarray = jobject.getAsJsonArray(currencyPair); JsonArray jarray = jobject.getAsJsonArray(currencyPair);
return jarray != null ? jarray.toString() : "[]"; return jarray != null ? jarray.toString() : "[]";
} }