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

[icloud] Fix NPE in AccountBridgeHandler #7087

Merged
merged 2 commits into from Mar 1, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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