From 34d6430c1a0568d073d00f78258d9b81d8b7c0f6 Mon Sep 17 00:00:00 2001 From: elroy Date: Sat, 1 Jul 2017 22:30:06 +0200 Subject: [PATCH] catch possible nullpointerexception if returned json does not contain our currency --- .../java/nl/komtek/gpi/controllers/GunbotProxyController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java b/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java index e201c97..ddb1f8d 100644 --- a/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java +++ b/src/main/java/nl/komtek/gpi/controllers/GunbotProxyController.java @@ -69,7 +69,7 @@ public class GunbotProxyController { JsonElement jelement = new JsonParser().parse(result); JsonObject jobject = jelement.getAsJsonObject(); JsonArray jarray = jobject.getAsJsonArray(currencyPair); - return jarray.toString(); + return jarray != null ? jarray.toString() : "[]"; } @RequestMapping(value = "/tradingApi/**", params = "command=returnTradeHistory") @@ -82,7 +82,7 @@ public class GunbotProxyController { JsonElement jelement = new JsonParser().parse(result); JsonObject jobject = jelement.getAsJsonObject(); JsonArray jarray = jobject.getAsJsonArray(currencyPair); - return jarray != null ? jarray.toString() : "[]"; + return jarray != null ? jarray.toString() : "[]"; }