Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bondhome] Fix fatal Null Pointer errors #14103

Merged
merged 4 commits into from
Dec 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public enum BondDeviceType {
FIREPLACE(THING_TYPE_BOND_FIREPLACE),
@SerializedName("GX")
GENERIC_DEVICE(THING_TYPE_BOND_GENERIC);
// TODO: add Light ("LT") type

private ThingTypeUID deviceTypeUid;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ public BondDevice getDevice(String deviceId) throws BondException {
String json = request("/v2/devices/" + deviceId);
logger.trace("BondHome device info : {}", json);
try {
return Objects.requireNonNull(gson.fromJson(json, BondDevice.class));
BondDevice device = Objects.requireNonNull(gson.fromJson(json, BondDevice.class));
device.actions.removeIf(Objects::isNull);
return device;
} catch (JsonParseException e) {
logger.debug("Could not parse device {}'s JSON '{}'", deviceId, json, e);
throw new BondException("@text/offline.comm-error.unparseable-response");
Expand Down Expand Up @@ -250,7 +252,7 @@ private synchronized String request(String uri) throws BondException {
logger.debug("Repeated Bond API calls to {} failed.", uri);
bridgeHandler.setBridgeOffline(ThingStatusDetail.COMMUNICATION_ERROR,
"@text/offline.comm-error.api-call-failed");
throw new BondException("@text/offline.conf-error.api-call-failed", true);
throw new BondException("@text/offline.comm-error.api-call-failed", true);
}
}
} while (true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ protected synchronized void startScan() {
for (final String deviceId : deviceList) {
BondDevice thisDevice = api.getDevice(deviceId);
String deviceName;
if ((deviceName = thisDevice.name) != null) {
if (thisDevice.type != null && (deviceName = thisDevice.name) != null) {
final ThingUID deviceUid = new ThingUID(thisDevice.type.getThingTypeUID(), bridgeUid, deviceId);
final DiscoveryResult discoveryResult = DiscoveryResultBuilder.create(deviceUid)
.withBridge(bridgeUid).withLabel(thisDevice.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ channel-type.bondhome.timerChannelType.description = Starts a timer for s second

# thing status descriptions

offline.comm-error.api-call-failed = Bond API call to {} failed: {}
offline.comm-error.api-call-failed = Bond API call failed.
offline.comm-error.device-not-found = No Bond device found with the given device id.
offline.comm-error.no-api = Bond Bridge API not available.
offline.comm-error.no-response = No response received!
Expand Down