From 8c685bcbbacc87c598c2b203d29673c22a792d0f Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Wed, 7 Oct 2026 23:05:34 -0400 Subject: [PATCH] =?UTF-8?q?test(ablegacy):=20make=20FakeAbLegacyTagFactory?= =?UTF-8?q?.Tags=20thread-safe=20=E2=80=94=20probe=20loop=20raced=20the=20?= =?UTF-8?q?test=20thread=20(#573)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe --- .../FakeAbLegacyTag.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/FakeAbLegacyTag.cs b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/FakeAbLegacyTag.cs index 4730777a..bd177379 100644 --- a/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/FakeAbLegacyTag.cs +++ b/tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.AbLegacy.Tests/FakeAbLegacyTag.cs @@ -115,8 +115,13 @@ internal class FakeAbLegacyTag : IAbLegacyTagRuntime /// Test factory for creating fake AbLegacy tags. internal sealed class FakeAbLegacyTagFactory : IAbLegacyTagFactory { - /// Gets the collection of created tags, keyed by tag name. - public Dictionary Tags { get; } = new(StringComparer.OrdinalIgnoreCase); + /// + /// Gets the collection of created tags, keyed by tag name. Concurrent on purpose (#573): the driver's + /// connectivity probe is on by default and creates its S:0 runtime from a thread-pool thread + /// while a test thread creates the tag under test, so a plain + /// here lost inserts (the "given key was not present" flake, ~1 run in 15). + /// + public System.Collections.Concurrent.ConcurrentDictionary Tags { get; } = new(StringComparer.OrdinalIgnoreCase); /// Gets or sets an optional customization function for tag creation. public Func? Customise { get; set; }