Skip to content

Commit

Permalink
fix(iot-serv): fix replace call on TwinClient (#1658)
Browse files Browse the repository at this point in the history
  • Loading branch information
brycewang-microsoft authored Jan 19, 2023
1 parent a5b5a1f commit c634fcd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,11 @@ public Twin replace(Twin twin, String ifMatch) throws IotHubException, IOExcepti
URL url;
if (twin.getModuleId() == null || twin.getModuleId().length() == 0)
{
url = this.iotHubConnectionString.getUrlTwin(twin.getDeviceId());
url = IotHubConnectionString.getUrlTwin(this.hostName, twin.getDeviceId());
}
else
{
url = this.iotHubConnectionString.getUrlModuleTwin(twin.getDeviceId(), twin.getModuleId());
url = IotHubConnectionString.getUrlModuleTwin(this.hostName, twin.getDeviceId(), twin.getModuleId());
}

TwinState twinState = new TwinState(twin.getTags(), twin.getDesiredProperties(), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,6 @@ private static void replaceDesiredProperties(TwinClient twinClient, Twin deviceT
{
deviceTwin.getDesiredProperties().put("temp", new Random().nextInt(TEMPERATURE_RANGE));

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

Expand Down

0 comments on commit c634fcd

Please sign in to comment.