mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-20 07:21:21 +02:00
Fix LogEntries: collection was modified exception (#309)
* _options.LogEntries.ToArray() * . * update error message
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VersionPrefix>1.0.25</VersionPrefix>
|
<VersionPrefix>1.0.27</VersionPrefix>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<Choose>
|
<Choose>
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
https://github.com/StefH/GitHubReleaseNotes
|
https://github.com/StefH/GitHubReleaseNotes
|
||||||
|
|
||||||
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --version 1.0.25.0
|
GitHubReleaseNotes.exe --output CHANGELOG.md --skip-empty-releases --version 1.0.27.0
|
||||||
@@ -80,11 +80,11 @@ namespace WireMock
|
|||||||
bool IsAdminInterface { get; }
|
bool IsAdminInterface { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ResponseToAsync
|
/// ProvideResponseAsync
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="requestMessage">The request message.</param>
|
/// <param name="requestMessage">The request message.</param>
|
||||||
/// <returns>The <see cref="ResponseMessage"/>.</returns>
|
/// <returns>The <see cref="ResponseMessage"/>.</returns>
|
||||||
Task<ResponseMessage> ResponseToAsync(RequestMessage requestMessage);
|
Task<ResponseMessage> ProvideResponseAsync(RequestMessage requestMessage);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the RequestMatchResult based on the RequestMessage.
|
/// Gets the RequestMatchResult based on the RequestMessage.
|
||||||
|
|||||||
@@ -77,8 +77,8 @@ namespace WireMock
|
|||||||
NextState = nextState;
|
NextState = nextState;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc cref="IMapping.ResponseToAsync" />
|
/// <inheritdoc cref="IMapping.ProvideResponseAsync" />
|
||||||
public async Task<ResponseMessage> ResponseToAsync(RequestMessage requestMessage)
|
public async Task<ResponseMessage> ProvideResponseAsync(RequestMessage requestMessage)
|
||||||
{
|
{
|
||||||
return await Provider.ProvideResponseAsync(requestMessage, Settings);
|
return await Provider.ProvideResponseAsync(requestMessage, Settings);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ namespace WireMock.Owin
|
|||||||
await Task.Delay(_options.RequestProcessingDelay.Value);
|
await Task.Delay(_options.RequestProcessingDelay.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
response = await targetMapping.ResponseToAsync(request);
|
response = await targetMapping.ProvideResponseAsync(request);
|
||||||
|
|
||||||
if (targetMapping.Scenario != null)
|
if (targetMapping.Scenario != null)
|
||||||
{
|
{
|
||||||
@@ -129,7 +129,7 @@ namespace WireMock.Owin
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_options.Logger.Error("HttpStatusCode set to 500");
|
_options.Logger.Error($"Providing a Response for Mapping '{result.TargetMapping.Guid}' failed. HttpStatusCode set to 500. Exception: {ex}");
|
||||||
response = ResponseMessageBuilder.Create(JsonConvert.SerializeObject(ex), 500);
|
response = ResponseMessageBuilder.Create(JsonConvert.SerializeObject(ex), 500);
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
|
|||||||
@@ -1,6 +1,3 @@
|
|||||||
using JetBrains.Annotations;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -8,6 +5,9 @@ using System.Linq;
|
|||||||
using System.Net.Http;
|
using System.Net.Http;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Linq;
|
||||||
using WireMock.Admin.Mappings;
|
using WireMock.Admin.Mappings;
|
||||||
using WireMock.Admin.Scenarios;
|
using WireMock.Admin.Scenarios;
|
||||||
using WireMock.Admin.Settings;
|
using WireMock.Admin.Settings;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ namespace WireMock.Server
|
|||||||
/// Gets the request logs.
|
/// Gets the request logs.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[PublicAPI]
|
[PublicAPI]
|
||||||
public IEnumerable<LogEntry> LogEntries => new ReadOnlyCollection<LogEntry>(_options.LogEntries);
|
public IEnumerable<LogEntry> LogEntries => new ReadOnlyCollection<LogEntry>(_options.LogEntries.ToArray());
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The search log-entries based on matchers.
|
/// The search log-entries based on matchers.
|
||||||
|
|||||||
29
src/WireMock.Net/Util/CloneUtils.cs
Normal file
29
src/WireMock.Net/Util/CloneUtils.cs
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
using FastDeepCloner;
|
||||||
|
using System;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
|
||||||
|
namespace WireMock.Util
|
||||||
|
{
|
||||||
|
internal static class CloneUtils
|
||||||
|
{
|
||||||
|
private static FastDeepClonerSettings settings = new FastDeepCloner.FastDeepClonerSettings()
|
||||||
|
{
|
||||||
|
FieldType = FastDeepCloner.FieldType.FieldInfo,
|
||||||
|
OnCreateInstance = new FastDeepCloner.Extensions.CreateInstance((Type type) =>
|
||||||
|
{
|
||||||
|
#if !NETSTANDARD1_3
|
||||||
|
return FormatterServices.GetUninitializedObject(type);
|
||||||
|
#else
|
||||||
|
|
||||||
|
#endif
|
||||||
|
})
|
||||||
|
};
|
||||||
|
|
||||||
|
public static T DeepClone<T>(T objectToBeCloned) where T : class
|
||||||
|
{
|
||||||
|
//return CloneExtensionsEx.CloneFactory.GetClone(objectToBeCloned);
|
||||||
|
// Expression.Lambda<Func<object>>(Expression.New(type)).Compile()
|
||||||
|
return FastDeepCloner.DeepCloner.Clone(objectToBeCloned, settings);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -45,6 +45,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Remove="Util\CloneUtils.cs" />
|
||||||
<Compile Remove="Util\IndexableDictionary.cs" />
|
<Compile Remove="Util\IndexableDictionary.cs" />
|
||||||
<Compile Remove="Util\NamedReaderWriterLocker.cs" />
|
<Compile Remove="Util\NamedReaderWriterLocker.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -64,6 +65,8 @@
|
|||||||
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.12" />
|
<PackageReference Include="System.Linq.Dynamic.Core" Version="1.0.12" />
|
||||||
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.8" />
|
<PackageReference Include="RandomDataGenerator.Net" Version="1.0.8" />
|
||||||
<PackageReference Include="JmesPath.Net" Version="1.0.125" />
|
<PackageReference Include="JmesPath.Net" Version="1.0.125" />
|
||||||
|
<!--<PackageReference Include="CloneExtensionsEx" Version="1.0.2" />-->
|
||||||
|
<!--<PackageReference Include="FastDeepCloner" Version="1.2.5" />-->
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
|
<ItemGroup Condition=" '$(TargetFramework)' == 'net451' ">
|
||||||
|
|||||||
Reference in New Issue
Block a user