mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
FindLogEntries exception 'Destination array was not long enough' #671
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @rinkeb on GitHub (Feb 25, 2025).
Originally assigned to: @StefH on GitHub.
Describe the bug
Intermittent exception when calling
WireMockServer.FindLogEntries:Message:
Stack Trace:
This only seems to happen when log entries are being added to WireMockMiddlewareOptions.LogEntries during the call to
FindLogEntries.Expected behavior:
No exception should be thrown.
Test to reproduce
FindLogEntrieswhile entries are added to source collection_options.LogEntries.Other related info
It looks like the generic
Enumerable.ToArrayimplementation called in public IReadOnlyList LogEntries => _options.LogEntries.ToArray(); for getting a snapshot of the log entries does not like it when the source collection grows while copying the items. A dedicated threadsafeToArrayimplementation onConcurrentObservableCollectionmight be the solution.Related: https://github.com/WireMock-Net/WireMock.Net/issues/1234
Using version 1.7.2
@StefH commented on GitHub (Feb 26, 2025):
"A dedicated threadsafe ToArray implementation on ConcurrentObservableCollection might be the solution"
--> Good suggestion !
@StefH commented on GitHub (Feb 26, 2025):
https://github.com/WireMock-Net/WireMock.Net/pull/1256