Skip to content

Commit

Permalink
Correctly close & dispose sdk client on fail to open (#7289)
Browse files Browse the repository at this point in the history
From syncing with SDK team in regards to how disposal of SDK client is supposed to work, we need to make sure we call closeAsync and dispose. Relying on just dispose may not correctly clean up resources in all cases.

## Azure IoT Edge PR checklist:
  • Loading branch information
nyanzebra authored Jun 20, 2024
1 parent 1f81779 commit df2f019
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 @@ -54,8 +54,7 @@ public async Task OpenAsync()
}
catch (Exception)
{
this.isActive.Set(false);
this.underlyingDeviceClient?.Dispose();
await this.CloseAsync();
throw;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ public async Task OpenAsync()
}
catch (Exception)
{
this.isActive.Set(false);
this.underlyingModuleClient?.Dispose();
await this.CloseAsync();
throw;
}
}
Expand Down

0 comments on commit df2f019

Please sign in to comment.