Skip to content

Commit

Permalink
[icloud] Fix NPE in AccountBridgeHandler (openhab#7087)
Browse files Browse the repository at this point in the history
* Fix NPE in AccountBridgeHandler

Signed-off-by: Kristof Rado <rado.krisi@gmail.com>
Signed-off-by: Hans-Reiner Hoffmann <hans-reiner.hoffmann@gmx.de>
  • Loading branch information
radokristof authored and Hans-Reiner committed Apr 11, 2020
1 parent 9f79e0a commit 038b965
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Expand Up @@ -13,6 +13,7 @@
package org.openhab.binding.icloud.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.icloud.internal.json.response.ICloudAccountDataResponse;

import com.google.gson.Gson;
Expand All @@ -29,7 +30,7 @@
public class ICloudDeviceInformationParser {
private final Gson gson = new GsonBuilder().create();

public ICloudAccountDataResponse parse(String json) throws JsonSyntaxException {
public @Nullable ICloudAccountDataResponse parse(String json) throws JsonSyntaxException {
return gson.fromJson(json, ICloudAccountDataResponse.class);
}
}
Expand Up @@ -65,7 +65,7 @@ public class ICloudAccountBridgeHandler extends BaseBridgeHandler {
@Nullable
ServiceRegistration<?> service;

private Object synchronizeRefresh = new Object();
private final Object synchronizeRefresh = new Object();

private List<ICloudDeviceInformationListener> deviceInformationListeners = Collections
.synchronizedList(new ArrayList<ICloudDeviceInformationListener>());
Expand Down Expand Up @@ -167,6 +167,9 @@ public void refreshData() {

try {
ICloudAccountDataResponse iCloudData = deviceInformationParser.parse(json);
if(iCloudData == null) {
return;
}
int statusCode = Integer.parseUnsignedInt(iCloudData.getICloudAccountStatusCode());
if (statusCode == 200) {
updateStatus(ThingStatus.ONLINE);
Expand Down

0 comments on commit 038b965

Please sign in to comment.