Skip to content

Commit

Permalink
(fix): Build error due to missing dispose (#1768)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinagesh authored Feb 4, 2021
1 parent adcb448 commit 529c504
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 2 additions & 0 deletions iothub/device/src/ClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ public static InternalClient Create(string hostname, string gatewayHostname, IAu
throw new ArgumentException("No certificate was found. To use certificate authentication certificate must be present.");
}

#pragma warning disable CA2000 // This is returned to client so cannot be disposed here.
InternalClient dc = CreateFromConnectionString(connectionStringBuilder.ToString(), PopulateCertificateInTransportSettings(connectionStringBuilder, transportType), options);
#pragma warning restore CA2000
dc.Certificate = connectionStringBuilder.Certificate;

// Install all the intermediate certificates in the chain if specified.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public IotHubConnectionStringBuilder Populate(IotHubConnectionStringBuilder iotH
throw new ArgumentNullException(nameof(iotHubConnectionStringBuilder));
}

iotHubConnectionStringBuilder.DeviceId = this.DeviceId;
iotHubConnectionStringBuilder.SharedAccessKey = this.KeyAsBase64String;
iotHubConnectionStringBuilder.DeviceId = DeviceId;
iotHubConnectionStringBuilder.SharedAccessKey = KeyAsBase64String;
iotHubConnectionStringBuilder.SharedAccessKeyName = null;
iotHubConnectionStringBuilder.SharedAccessSignature = null;

Expand Down
2 changes: 2 additions & 0 deletions iothub/device/src/Edge/EdgeModuleClientFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ private async Task<ModuleClient> CreateInternalClientFromEnvironmentAsync()
}

ISignatureProvider signatureProvider = new HttpHsmSignatureProvider(edgedUri, DefaultApiVersion);
#pragma warning disable CA2000 // This is disposed when the client is disposed.
var authMethod = new ModuleAuthenticationWithHsm(signatureProvider, deviceId, moduleId, generationId);
#pragma warning restore CA2000

Debug.WriteLine("EdgeModuleClientFactory setupTrustBundle from service");

Expand Down
6 changes: 6 additions & 0 deletions iothub/device/src/InternalClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1974,11 +1974,17 @@ internal void ValidateModuleTransportHandler(string apiName)
public void Dispose()
{
InnerHandler?.Dispose();
InnerHandler = null;
_methodsDictionarySemaphore?.Dispose();
_moduleReceiveMessageSemaphore?.Dispose();
_fileUploadHttpTransportHandler?.Dispose();
_deviceReceiveMessageSemaphore?.Dispose();
_twinDesiredPropertySemaphore?.Dispose();
#if !NET451
Certificate?.Dispose();
Certificate = null;
#endif
IotHubConnectionString?.TokenRefresher?.Dispose();
}

internal bool IsE2EDiagnosticSupportedProtocol()
Expand Down

0 comments on commit 529c504

Please sign in to comment.