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

[orbitbhyve] Handle null location attribute in devices json #16525

Merged
merged 2 commits into from
Mar 16, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import org.slf4j.LoggerFactory;

import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;

/**
* The {@link OrbitBhyveBridgeHandler} is responsible for handling commands, which are
Expand Down Expand Up @@ -210,6 +211,9 @@ public List<OrbitBhyveDevice> getDevices() {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Get devices returned response status: " + response.getStatus());
}
} catch (JsonSyntaxException e) {
logger.debug("Exception parsing devices json: {}", e.getMessage(), e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Error parsing devices json");
} catch (TimeoutException | ExecutionException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Error during getting devices");
} catch (InterruptedException e) {
Expand Down Expand Up @@ -237,6 +241,9 @@ Request sendRequestBuilder(String uri, HttpMethod method) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Returned status: " + response.getStatus());
}
} catch (JsonSyntaxException e) {
logger.debug("Exception parsing device json: {}", e.getMessage(), e);
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, "Error parsing device json");
} catch (TimeoutException | ExecutionException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
"Error during getting device info: " + deviceId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import java.util.List;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.annotations.SerializedName;

Expand Down Expand Up @@ -52,7 +54,8 @@ public class OrbitBhyveDevice {
@SerializedName("last_connected_at")
String lastConnectedAt = "";

JsonObject location = new JsonObject();
@Nullable
JsonElement location = null;

@SerializedName("suggested_start_time")
String suggestedStartTime = "";
Expand Down