Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FindLogEntries regression #1234

Closed
rinkeb opened this issue Jan 9, 2025 · 2 comments · Fixed by #1235
Closed

FindLogEntries regression #1234

rinkeb opened this issue Jan 9, 2025 · 2 comments · Fixed by #1235
Assignees
Labels

Comments

@rinkeb
Copy link

rinkeb commented Jan 9, 2025

Describe the bug

It looks like 1.6.11 has a regression in method WireMockServer.FindLogEntries. After NuGet upgrade, this exception is sometimes thrown:

 ---> System.ArgumentException: Destination array was not long enough. Check the destination index, length, and the array's lower bounds. (Parameter 'destinationArray')
   at System.Array.CopyImpl(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
   at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)
   at System.Collections.Generic.List`1.CopyTo(T[] array, Int32 arrayIndex)
   at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)
   at WireMock.Server.WireMockServer.FindLogEntries(IRequestMatcher[] matchers)

This seems to happen intermittently, most likely due to concurrency.

Looking at this change , I suspect that the apparent regression is caused by the change from ToList() to ToArray().
When new log entries are added to _options.LogEntries while creating the array, the input collection becomes larger than the allocated array during copying. Previously the target list could grow, but the array cannot.

Expected behavior:

No exception.

Test to reproduce

Add items to _options.LogEntries during the call to _options.LogEntries.ToArray()

Other related info

Using .NET 9 SDK and Runtime

@rinkeb rinkeb added the bug label Jan 9, 2025
@StefH StefH changed the title FindLogEntries regression? FindLogEntries regression Jan 9, 2025
@StefH StefH self-assigned this Jan 9, 2025
@StefH
Copy link
Collaborator

StefH commented Jan 9, 2025

Thanks for noticing.

Can you try preview 1.6.11-ci-19560 ?
https://github.com/WireMock-Net/WireMock.Net/wiki/MyGet-preview-versions

@rinkeb
Copy link
Author

rinkeb commented Jan 9, 2025

@StefH cannot reproduce the issue anymore, so it looks like its working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants