[sensebox] Fix NPE (#14879)
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
committed by
GitHub
parent
fafcc68423
commit
b07dd3c48f
@@ -71,6 +71,7 @@ public class SenseBoxAPIConnection {
|
|||||||
logger.trace("Fetched Data: {}", body);
|
logger.trace("Fetched Data: {}", body);
|
||||||
SenseBoxData parsedData = gson.fromJson(body, SenseBoxData.class);
|
SenseBoxData parsedData = gson.fromJson(body, SenseBoxData.class);
|
||||||
|
|
||||||
|
if (parsedData != null) {
|
||||||
// Assume all is well at first
|
// Assume all is well at first
|
||||||
parsedData.setStatus(ThingStatus.ONLINE);
|
parsedData.setStatus(ThingStatus.ONLINE);
|
||||||
|
|
||||||
@@ -151,6 +152,11 @@ public class SenseBoxAPIConnection {
|
|||||||
logger.trace("=================================");
|
logger.trace("=================================");
|
||||||
|
|
||||||
result = parsedData;
|
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) {
|
} catch (JsonSyntaxException e) {
|
||||||
logger.debug("An error occurred while parsing the data into desired class: {} / {} / {}", body,
|
logger.debug("An error occurred while parsing the data into desired class: {} / {} / {}", body,
|
||||||
SenseBoxData.class.getName(), e.getMessage());
|
SenseBoxData.class.getName(), e.getMessage());
|
||||||
@@ -159,7 +165,6 @@ public class SenseBoxAPIConnection {
|
|||||||
logger.debug("IO problems while fetching data: {} / {}", query, e.getMessage());
|
logger.debug("IO problems while fetching data: {} / {}", query, e.getMessage());
|
||||||
result.setStatus(ThingStatus.OFFLINE);
|
result.setStatus(ThingStatus.OFFLINE);
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user