Skip to content

Commit 5861c7a

Browse files
committed
Add explicit null check for _connector before ReadBatchAsync
Improved safety by adding an explicit null check for _connector before calling ReadBatchAsync in SortIdentitiesAsync. This change clarifies intent and prevents potential null reference issues.
1 parent bf971df commit 5861c7a

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

src/AXSharp.connectors/src/AXSharp.Connector/Identity/TwinIdentityProvider.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,10 @@ internal async Task SortIdentitiesAsync()
250250
await Task.Run(async () =>
251251
{
252252
_connector?.Logger.Information("Sorting identities...");
253-
await _connector?.ReadBatchAsync(_identities.Select(p => p.Key), eAccessPriority.High);
253+
if (_connector != null)
254+
{
255+
await _connector?.ReadBatchAsync(_identities.Select(p => p.Key), eAccessPriority.High);
256+
}
254257
_sortedIdentities.Clear();
255258
foreach (var identity in _identities)
256259
{

0 commit comments

Comments
 (0)