diff --git a/CHANGELOG.md b/CHANGELOG.md
index d2008c08..0a986fc4 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+# 1.5.11 (24 November 2022)
+- [#836](https://github.com/WireMock-Net/WireMock.Net/pull/836) - Add Settings.QueryParameterMultipleValueSupport [feature] contributed by [StefH](https://github.com/StefH)
+- [#848](https://github.com/WireMock-Net/WireMock.Net/pull/848) - Use try-catch when adding or removing logEntry [bug] contributed by [StefH](https://github.com/StefH)
+- [#846](https://github.com/WireMock-Net/WireMock.Net/issues/846) - Exception ArgumentOutOfRangeException [bug]
+
# 1.5.10 (06 November 2022)
- [#843](https://github.com/WireMock-Net/WireMock.Net/pull/843) - Webhook Templating: Use the transformed URL to create the HttpRequestMessage contributed by [ggradnig](https://github.com/ggradnig)
- [#845](https://github.com/WireMock-Net/WireMock.Net/pull/845) - Add WireMockNullLogger as valid commandline logger option [feature] contributed by [StefH](https://github.com/StefH)
diff --git a/Directory.Build.props b/Directory.Build.props
index 6ec53d29..a051c5a1 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -4,7 +4,7 @@
- 1.5.10
+ 1.5.11
WireMock.Net-Logo.png
https://github.com/WireMock-Net/WireMock.Net
Apache-2.0
@@ -20,6 +20,13 @@
true
+
+
+ true
+ GeneratedCodeAttribute
+ opencover
+
+
diff --git a/Generate-ReleaseNotes.cmd b/Generate-ReleaseNotes.cmd
index 6468ffae..dfe38106 100644
--- a/Generate-ReleaseNotes.cmd
+++ b/Generate-ReleaseNotes.cmd
@@ -1,6 +1,6 @@
rem https://github.com/StefH/GitHubReleaseNotes
-SET version=1.5.10
+SET version=1.5.11
GitHubReleaseNotes --output CHANGELOG.md --skip-empty-releases --exclude-labels question invalid doc duplicate --version %version% --token %GH_TOKEN%
diff --git a/PackageReleaseNotes.txt b/PackageReleaseNotes.txt
index d3e6f892..4f99d97f 100644
--- a/PackageReleaseNotes.txt
+++ b/PackageReleaseNotes.txt
@@ -1,5 +1,6 @@
-# 1.5.10 (06 November 2022)
-- #843 Webhook Templating: Use the transformed URL to create the HttpRequestMessage
-- #845 Add WireMockNullLogger as valid commandline logger option [feature]
+# 1.5.11 (24 November 2022)
+- #836 Add Settings.QueryParameterMultipleValueSupport [feature]
+- #848 Use try-catch when adding or removing logEntry [bug]
+- #846 Exception ArgumentOutOfRangeException [bug]
The full release notes can be found here: https://github.com/WireMock-Net/WireMock.Net/blob/master/CHANGELOG.md
\ No newline at end of file
diff --git a/azure-pipelines-ci.yml b/azure-pipelines-ci.yml
index 5eee61f5..d1ca4c6d 100644
--- a/azure-pipelines-ci.yml
+++ b/azure-pipelines-ci.yml
@@ -43,14 +43,12 @@ jobs:
command: 'build'
projects: './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj'
arguments: '--configuration Debug --framework net6.0'
-
- - task: DotNetCoreCLI@2
- displayName: 'Execute Unit tests'
+
+ - task: CmdLine@2
inputs:
- command: 'test'
- projects: './test/WireMock.Net.Tests/WireMock.Net.Tests.csproj'
- arguments: '--no-build --configuration Debug --framework net6.0 --collect:"XPlat Code Coverage" --logger trx /p:CollectCoverage=true /p:CoverletOutputFormat=opencover'
-
+ script: 'dotnet test ./test/WireMock.Net.Tests/WireMock.Net.Tests.csproj --no-build --configuration Debug --framework net6.0'
+ displayName: 'Execute Unit Tests with Coverage'
+
- task: SonarCloudAnalyze@1
displayName: 'SonarCloud: Run Code Analysis'
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest')) # Do not run for PullRequests
@@ -76,7 +74,7 @@ jobs:
- task: PublishBuildArtifacts@1
displayName: Publish coverage file
inputs:
- PathtoPublish: '/home/vsts/work/1/s/test/WireMock.Net.Tests/coverage.net6.0.opencover.xml'
+ PathtoPublish: './test/WireMock.Net.Tests/coverage.net6.0.opencover.xml'
- job: Windows_Build_Test
diff --git a/examples/WireMock.Net.Service/App.config b/examples/WireMock.Net.Service/App.config
index 0819f408..aa4814ca 100644
--- a/examples/WireMock.Net.Service/App.config
+++ b/examples/WireMock.Net.Service/App.config
@@ -1,14 +1,14 @@
-
+
-
+
-
-
+
+
-
\ No newline at end of file
+
diff --git a/examples/WireMock.Net.Service/WireMock.Net.Service.csproj b/examples/WireMock.Net.Service/WireMock.Net.Service.csproj
index 3b135fc1..193ff51f 100644
--- a/examples/WireMock.Net.Service/WireMock.Net.Service.csproj
+++ b/examples/WireMock.Net.Service/WireMock.Net.Service.csproj
@@ -8,9 +8,10 @@
Exe
WireMock.Net.Service
WireMock.Net.Service
- v4.5.2
+ v4.8
512
true
+
AnyCPU
diff --git a/examples/WireMock.Net.Service/packages.config b/examples/WireMock.Net.Service/packages.config
index 1dae1526..4c8969d8 100644
--- a/examples/WireMock.Net.Service/packages.config
+++ b/examples/WireMock.Net.Service/packages.config
@@ -11,6 +11,6 @@
-
+
\ No newline at end of file
diff --git a/src/WireMock.Net/Owin/WireMockMiddleware.cs b/src/WireMock.Net/Owin/WireMockMiddleware.cs
index d78d4a35..1c4d8dee 100644
--- a/src/WireMock.Net/Owin/WireMockMiddleware.cs
+++ b/src/WireMock.Net/Owin/WireMockMiddleware.cs
@@ -269,29 +269,55 @@ namespace WireMock.Owin
{
_options.Logger.DebugRequestResponse(_logEntryMapper.Map(entry), entry.RequestMessage.Path.StartsWith("/__admin/"));
- if (addRequest)
+ // If addRequest is set to true and MaxRequestLogCount is null or does have a value greater than 0, try to add a new request log.
+ if (addRequest && _options.MaxRequestLogCount is null or > 0)
{
- _options.LogEntries.Add(entry);
+ TryAddLogEntry(entry);
}
- if (_options.MaxRequestLogCount != null)
+ // In case MaxRequestLogCount has a value greater than 0, try to delete existing request logs based on the count.
+ if (_options.MaxRequestLogCount is > 0)
{
var logEntries = _options.LogEntries.ToList();
foreach (var logEntry in logEntries.OrderBy(le => le.RequestMessage.DateTime).Take(logEntries.Count - _options.MaxRequestLogCount.Value))
{
- _options.LogEntries.Remove(logEntry);
+ TryRemoveLogEntry(logEntry);
}
}
- if (_options.RequestLogExpirationDuration != null)
+ // In case RequestLogExpirationDuration has a value greater than 0, try to delete existing request logs based on the date.
+ if (_options.RequestLogExpirationDuration is > 0)
{
var checkTime = DateTime.UtcNow.AddHours(-_options.RequestLogExpirationDuration.Value);
-
foreach (var logEntry in _options.LogEntries.ToList().Where(le => le.RequestMessage.DateTime < checkTime))
{
- _options.LogEntries.Remove(logEntry);
+ TryRemoveLogEntry(logEntry);
}
}
}
+
+ private void TryAddLogEntry(LogEntry logEntry)
+ {
+ try
+ {
+ _options.LogEntries.Add(logEntry);
+ }
+ catch
+ {
+ // Ignore exception (can happen during stress testing)
+ }
+ }
+
+ private void TryRemoveLogEntry(LogEntry logEntry)
+ {
+ try
+ {
+ _options.LogEntries.Remove(logEntry);
+ }
+ catch
+ {
+ // Ignore exception (can happen during stress testing)
+ }
+ }
}
}
\ No newline at end of file
diff --git a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj
index 8c3eb968..794e4038 100644
--- a/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj
+++ b/test/WireMock.Net.Tests/WireMock.Net.Tests.csproj
@@ -31,17 +31,17 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/test/WireMock.Net.Tests/WireMockServer.Admin.cs b/test/WireMock.Net.Tests/WireMockServer.Admin.cs
index f299c17d..96f13347 100644
--- a/test/WireMock.Net.Tests/WireMockServer.Admin.cs
+++ b/test/WireMock.Net.Tests/WireMockServer.Admin.cs
@@ -5,6 +5,7 @@ using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
+using FluentAssertions;
using Moq;
using Newtonsoft.Json;
using NFluent;
@@ -374,6 +375,26 @@ public class WireMockServerAdminTests
server.Stop();
}
+ [Fact]
+ public async Task WireMockServer_Admin_Logging_SetMaxRequestLogCount_To_0_Should_Not_AddLogging()
+ {
+ // Assign
+ var client = new HttpClient();
+
+ // Act
+ var server = WireMockServer.Start();
+ server.SetMaxRequestLogCount(0);
+
+ await client.GetAsync("http://localhost:" + server.Port + "/foo1").ConfigureAwait(false);
+ await client.GetAsync("http://localhost:" + server.Port + "/foo2").ConfigureAwait(false);
+ await client.GetAsync("http://localhost:" + server.Port + "/foo3").ConfigureAwait(false);
+
+ // Assert
+ server.LogEntries.Should().BeEmpty();
+
+ server.Stop();
+ }
+
[Fact]
public void WireMockServer_Admin_WatchStaticMappings()
{