Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(fix): Build error due to missing dispose #1768

Merged
merged 2 commits into from
Feb 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to dispose whatever is needed here. Making the IotHubConnectionString class did not seem right as we really do not want that dispose to be called anywhere else.

}

internal bool IsE2EDiagnosticSupportedProtocol()
Expand Down