From d98b32640bb5429e4ff56e1580dd47d84db2af36 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Fri, 24 Jul 2026 02:08:05 -0400 Subject: [PATCH] docs(mesh): correct the all-malformed-cluster comments in CentralCommunicationActor The per-cluster contact map only gains a key when a row parses, so an all-malformed cluster has no key at all and is caught by the absent-key arm; the empty-set guard is defensive/unreachable for the DB producer. Comment-only (Task 4 code-review minor follow-up). Claude-Session: https://claude.ai/code/session_01GASWkNEi68FSCtvr6rLoEW --- .../Communication/CentralCommunicationActor.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/Communication/CentralCommunicationActor.cs b/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/Communication/CentralCommunicationActor.cs index f400ea17..0c470ede 100644 --- a/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/Communication/CentralCommunicationActor.cs +++ b/src/Server/ZB.MOM.WW.OtOpcUa.ControlPlane/Communication/CentralCommunicationActor.cs @@ -258,8 +258,9 @@ public sealed class CentralCommunicationActor : ReceiveActor, IWithTimers kv => kv.Key, kv => kv.Value.ToImmutableHashSet()); // Clusters that dropped out of the DB entirely, or whose only rows were malformed this refresh: - // stop and forget their clients so a vanished cluster stops receiving. A cluster whose rows all - // went malformed lands here via the empty-set branch. + // stop and forget their clients so a vanished cluster stops receiving. LoadContactsFromDb only + // creates a ByCluster key when at least one of its rows parsed, so an all-malformed cluster has + // NO key at all and is caught here by the absent-key (!TryGetValue) arm — not by an empty value. var gone = _clients.Keys .Where(id => !byCluster.TryGetValue(id, out var c) || c.IsEmpty) .ToList(); @@ -277,8 +278,10 @@ public sealed class CentralCommunicationActor : ReceiveActor, IWithTimers { if (contacts.IsEmpty) { - // Only-malformed rows for this cluster this refresh. Warn per cluster; its client (if - // any) was already stopped above. + // Defensive: LoadContactsFromDb never emits an empty-but-present cluster (a key is + // created only on a first successfully-parsed row), so this arm is unreachable for the + // DB producer — an all-malformed cluster is handled by the absent-key branch above. It + // guards a ContactsLoaded (a public record) constructed elsewhere with an empty list. _log.Warning( "Cluster {ClusterId} has no usable ClusterNode contact points; no ClusterClient " + "was created for it and its nodes' commands will be dropped until a refresh finds "