diff --git a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway/GatewayHistorianDataSource.cs b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway/GatewayHistorianDataSource.cs
index e263ae36..5a85ef63 100644
--- a/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway/GatewayHistorianDataSource.cs
+++ b/src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway/GatewayHistorianDataSource.cs
@@ -335,8 +335,8 @@ public sealed class GatewayHistorianDataSource : IHistorianDataSource, IAsyncDis
}
}
- /// Disposes the underlying gateway client.
- public void Dispose() => _client.DisposeAsync().AsTask().GetAwaiter().GetResult();
+ /// Disposes the underlying gateway client. Prefer .
+ public void Dispose() => DisposeAsync().AsTask().GetAwaiter().GetResult();
/// Asynchronously disposes the underlying gateway client.
/// A task that completes when the client has been disposed.
diff --git a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests/GatewayHistorianDataSourceTests.cs b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests/GatewayHistorianDataSourceTests.cs
index 0e7abcbd..423d9b03 100644
--- a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests/GatewayHistorianDataSourceTests.cs
+++ b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Historian.Gateway.Tests/GatewayHistorianDataSourceTests.cs
@@ -69,6 +69,15 @@ public sealed class GatewayHistorianDataSourceTests
Assert.Equal(1, fake.DisposeCallCount);
}
+ [Fact]
+ public void Dispose_via_sync_path_disposes_client()
+ {
+ var fake = new FakeHistorianGatewayClient();
+ var ds = new GatewayHistorianDataSource(fake, NullLogger.Instance);
+ ((IDisposable)ds).Dispose();
+ Assert.Equal(1, fake.DisposeCallCount);
+ }
+
// Ts(...) builds a Google.Protobuf.WellKnownTypes.Timestamp from UTC parts.
private static Timestamp Ts(int y, int mo, int d, int h, int mi, int s)
=> Timestamp.FromDateTime(new DateTime(y, mo, d, h, mi, s, DateTimeKind.Utc));