refactoring

This commit is contained in:
dashevchenko 2025-03-19 18:33:55 +02:00
parent b758a1c7d0
commit 0270bc9b88
2 changed files with 6 additions and 6 deletions

View File

@ -201,7 +201,7 @@ public class DeviceConnectivityServiceImpl implements DeviceConnectivityService
pemContentBuilder.append("-----END CERTIFICATE-----\n");
}
}
} catch (IOException e) {
} catch (Exception e) {
String msg = String.format("Failed to read %s server certificate!", path);
log.warn(msg);
throw new RuntimeException(msg, e);

View File

@ -214,24 +214,24 @@ public class DeviceConnectivityUtil {
return null;
}
StringBuilder mqttDockerCommand = new StringBuilder();
mqttDockerCommand.append(DOCKER_RUN).append(isLocalhost(host) ? ADD_DOCKER_INTERNAL_HOST : "").append(COAP_IMAGE);
StringBuilder coapDockerCommand = new StringBuilder();
coapDockerCommand.append(DOCKER_RUN).append(isLocalhost(host) ? ADD_DOCKER_INTERNAL_HOST : "").append(COAP_IMAGE);
if (isLocalhost(host)) {
coapCommand = coapCommand.replace(host, HOST_DOCKER_INTERNAL);
}
if (COAPS.equals(protocol)) {
mqttDockerCommand.append("/bin/sh -c \"")
coapDockerCommand.append("/bin/sh -c \"")
.append(getCurlPemCertCommand(baseUrl, protocol))
.append(" && ")
.append(coapCommand)
.append("\"");
} else {
mqttDockerCommand.append(coapCommand);
coapDockerCommand.append(coapCommand);
}
return mqttDockerCommand.toString();
return coapDockerCommand.toString();
}
public static String getHost(String baseUrl, DeviceConnectivityInfo properties, String protocol) throws URISyntaxException {