added notnull check for http commands

This commit is contained in:
dashevchenko 2023-07-20 15:33:02 +03:00
parent db46b7988d
commit e3ef58c603

View File

@ -119,8 +119,10 @@ public class DeviceСonnectivityServiceImpl implements DeviceConnectivityService
private JsonNode getHttpTransportPublishCommands(String defaultHostname, DeviceCredentials deviceCredentials) { private JsonNode getHttpTransportPublishCommands(String defaultHostname, DeviceCredentials deviceCredentials) {
ObjectNode httpCommands = JacksonUtil.newObjectNode(); ObjectNode httpCommands = JacksonUtil.newObjectNode();
httpCommands.put(HTTP, getHttpPublishCommand(HTTP, defaultHostname, deviceCredentials)); Optional.ofNullable(getHttpPublishCommand(HTTP, defaultHostname, deviceCredentials))
httpCommands.put(HTTPS, getHttpPublishCommand(HTTPS, defaultHostname, deviceCredentials)); .ifPresent(v -> httpCommands.put(HTTP, v));
Optional.ofNullable(getHttpPublishCommand(HTTPS, defaultHostname, deviceCredentials))
.ifPresent(v -> httpCommands.put(HTTPS, v));
return httpCommands; return httpCommands;
} }