From 2c6623ed8397b56231fdc8402ab1be8190732360 Mon Sep 17 00:00:00 2001 From: Damyan Ivanov Date: Mon, 30 Aug 2021 19:07:37 +0300 Subject: [PATCH] config restore: skip null entries instead of crashing because they aren't 'String' etc. --- .../ktnx/mobileledger/async/ConfigReader.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/app/src/main/java/net/ktnx/mobileledger/async/ConfigReader.java b/app/src/main/java/net/ktnx/mobileledger/async/ConfigReader.java index bc95a8f8..a894f92f 100644 --- a/app/src/main/java/net/ktnx/mobileledger/async/ConfigReader.java +++ b/app/src/main/java/net/ktnx/mobileledger/async/ConfigReader.java @@ -69,6 +69,10 @@ public class ConfigReader extends ConfigIO { r.beginObject(); while (r.hasNext()) { String item = r.nextName(); + if (r.peek() == JsonToken.NULL) { + r.nextNull(); + continue; + } switch (item) { case Keys.COMMODITIES: commodities = readCommodities(r); @@ -150,6 +154,10 @@ public class ConfigReader extends ConfigIO { TemplateAccount result = new TemplateAccount(0L, 0L, 0L); while (r.peek() != JsonToken.END_OBJECT) { String item = r.nextName(); + if (r.peek() == JsonToken.NULL) { + r.nextNull(); + continue; + } switch (item) { case Keys.NAME: result.setAccountName(r.nextString()); @@ -195,6 +203,10 @@ public class ConfigReader extends ConfigIO { while (r.peek() != JsonToken.END_OBJECT) { String item = r.nextName(); + if (r.peek() == JsonToken.NULL) { + r.nextNull(); + continue; + } switch (item) { case Keys.UUID: t.setUuid(r.nextString()); @@ -280,6 +292,10 @@ public class ConfigReader extends ConfigIO { r.beginObject(); while (r.peek() != JsonToken.END_OBJECT) { final String item = r.nextName(); + if (r.peek() == JsonToken.NULL) { + r.nextNull(); + continue; + } switch (item) { case Keys.NAME: c.setName(r.nextString()); @@ -314,6 +330,10 @@ public class ConfigReader extends ConfigIO { r.beginObject(); while (r.peek() != JsonToken.END_OBJECT) { String item = r.nextName(); + if (r.peek() == JsonToken.NULL) { + r.nextNull(); + continue; + } switch (item) { case Keys.UUID: -- 2.39.5