From 992d834398c86d01eeb3c4ac4425030e2e5c31eb Mon Sep 17 00:00:00 2001 From: John Simons Date: Fri, 9 Oct 2026 12:30:25 +1000 Subject: [PATCH] Copy broker metadata into the report instead of sharing the stored dictionary EnvironmentData referenced the same dictionary instance returned by the broker metadata store, so later mutations of the report data could leak back into persisted state. Assign a new dictionary when building the report and add a test asserting stored broker metadata stays unchanged after generating a report. --- ...utCollector_Report_EnvironmentInformation_Tests.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs index b91bac763e..0d6483c666 100644 --- a/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs +++ b/src/Particular.LicensingComponent.UnitTests/ThroughputCollector/ThroughputCollector_Report_EnvironmentInformation_Tests.cs @@ -197,6 +197,17 @@ await DataStore.CreateBuilder() Assert.That(report.ReportData.ScopeType, Is.EqualTo(expectedScopeType), $"Invalid ScopeType on report"); } + [Test] + public async Task Should_leave_the_stored_broker_metadata_unchanged() + { + await DataStore.SaveBrokerMetadata(new BrokerMetadata("testingScope", new Dictionary { [EnvironmentDataType.BrokerVersion.ToString()] = "1.2" })); + + await ThroughputCollector.GenerateThroughputReport("", null); + + var stored = await DataStore.GetBrokerMetadata(); + Assert.That(stored.Data.Keys, Is.EquivalentTo(new[] { EnvironmentDataType.BrokerVersion.ToString() })); + } + [Test] public async Task Should_include_audit_instance_counts_in_environment_data() {