[sensebox] Fix NPE (#14879)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2023-05-01 19:44:08 +02:00 committed by GitHub
parent fafcc68423
commit b07dd3c48f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -71,6 +71,7 @@ public class SenseBoxAPIConnection {
logger.trace("Fetched Data: {}", body);
SenseBoxData parsedData = gson.fromJson(body, SenseBoxData.class);
if (parsedData != null) {
// Assume all is well at first
parsedData.setStatus(ThingStatus.ONLINE);
@ -151,6 +152,11 @@ public class SenseBoxAPIConnection {
logger.trace("=================================");
result = parsedData;
} else {
logger.debug("An error occurred while parsing the data into desired class: {} / {}", body,
SenseBoxData.class.getName());
result.setStatus(ThingStatus.OFFLINE);
}
} catch (JsonSyntaxException e) {
logger.debug("An error occurred while parsing the data into desired class: {} / {} / {}", body,
SenseBoxData.class.getName(), e.getMessage());
@ -159,7 +165,6 @@ public class SenseBoxAPIConnection {
logger.debug("IO problems while fetching data: {} / {}", query, e.getMessage());
result.setStatus(ThingStatus.OFFLINE);
}
return result;
}
}