From 4dde47bc44562d5082516ca65296b92d318b7773 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 27 Oct 2023 21:48:24 +0200 Subject: [PATCH] NSCv1: catch misformatted devicestatus --- .../aaps/plugins/sync/nsclient/services/NSClientService.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/nsclient/services/NSClientService.kt b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/nsclient/services/NSClientService.kt index c05558ec8c..c6ddabc390 100644 --- a/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/nsclient/services/NSClientService.kt +++ b/plugins/sync/src/main/kotlin/app/aaps/plugins/sync/nsclient/services/NSClientService.kt @@ -524,7 +524,11 @@ class NSClientService : DaggerService() { } } - val devicestatuses = gson.fromJson(data.getString("devicestatus"), Array::class.java) + val devicestatuses = try { + gson.fromJson(data.getString("devicestatus"), Array::class.java) + } catch (unused: Exception) { + emptyArray() + } if (devicestatuses.isNotEmpty()) { rxBus.send(EventNSClientNewLog("◄ DATA", "received " + devicestatuses.size + " device statuses")) nsDeviceStatusHandler.handleNewData(devicestatuses)