Skip to content

Commit c634fcd

Browse files
fix(iot-serv): fix replace call on TwinClient (#1658)
1 parent a5b5a1f commit c634fcd

File tree

2 files changed

+2
-4
lines changed
  • service
    • iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/twin
    • iot-service-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot

2 files changed

+2
-4
lines changed

service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/twin/TwinClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,11 @@ public Twin replace(Twin twin, String ifMatch) throws IotHubException, IOExcepti
321321
URL url;
322322
if (twin.getModuleId() == null || twin.getModuleId().length() == 0)
323323
{
324-
url = this.iotHubConnectionString.getUrlTwin(twin.getDeviceId());
324+
url = IotHubConnectionString.getUrlTwin(this.hostName, twin.getDeviceId());
325325
}
326326
else
327327
{
328-
url = this.iotHubConnectionString.getUrlModuleTwin(twin.getDeviceId(), twin.getModuleId());
328+
url = IotHubConnectionString.getUrlModuleTwin(this.hostName, twin.getDeviceId(), twin.getModuleId());
329329
}
330330

331331
TwinState twinState = new TwinState(twin.getTags(), twin.getDesiredProperties(), null);

service/iot-service-samples/device-twin-sample/src/main/java/samples/com/microsoft/azure/sdk/iot/DeviceTwinSample.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ private static void replaceDesiredProperties(TwinClient twinClient, Twin deviceT
105105
{
106106
deviceTwin.getDesiredProperties().put("temp", new Random().nextInt(TEMPERATURE_RANGE));
107107

108-
// By replacing the twin rather than patching it, any desired properties that existed on the twin prior to this call
109-
// that aren't present on the new set of desired properties will be deleted.
110108
System.out.println("Replacing Device twin");
111109
deviceTwin = twinClient.replace(deviceTwin);
112110

0 commit comments

Comments
 (0)