From 8ce12d61c0c9074a4bb8264d907c708d7adae630 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Wed, 22 Mar 2023 22:09:43 +0100 Subject: [PATCH] Xdrip: prevent NPE --- .../java/info/nightscout/plugins/sync/xdrip/XdripPlugin.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/plugins/sync/src/main/java/info/nightscout/plugins/sync/xdrip/XdripPlugin.kt b/plugins/sync/src/main/java/info/nightscout/plugins/sync/xdrip/XdripPlugin.kt index c2a5d9a91f..b683422596 100644 --- a/plugins/sync/src/main/java/info/nightscout/plugins/sync/xdrip/XdripPlugin.kt +++ b/plugins/sync/src/main/java/info/nightscout/plugins/sync/xdrip/XdripPlugin.kt @@ -362,10 +362,8 @@ class XdripPlugin @Inject constructor( private fun sendEntries(dataPairs: List, progress: String) { val array = JSONArray() - for (dataPair in dataPairs) { - val data = (dataPair as DataSyncSelector.PairGlucoseValue).value.toXdripJson() - array.put(data) - } + for (dataPair in dataPairs) + (dataPair as DataSyncSelector.PairGlucoseValue?)?.value?.toXdripJson()?.also { gv -> array.put(gv) } rxBus.send(EventXdripNewLog("SENDING", "Sent ${array.length()} BGs ($progress)")) broadcast( Intent(Intents.ACTION_NEW_SGV)