This commit is contained in:
Stef Heyenrath
2019-09-17 18:13:01 +02:00
committed by GitHub
parent 5b8b588983
commit e1798fbb8e
7 changed files with 23 additions and 13 deletions

View File

@@ -1,9 +1,9 @@
using System;
using System.Collections.Concurrent;
using System.Collections.ObjectModel;
using WireMock.Handlers;
using WireMock.Logging;
using WireMock.Matchers;
using WireMock.Util;
#if !USE_ASPNETCORE
using Owin;
#else
@@ -26,7 +26,7 @@ namespace WireMock.Owin
ConcurrentDictionary<string, ScenarioState> Scenarios { get; }
ObservableCollection<LogEntry> LogEntries { get; }
ConcurrentObservableCollection<LogEntry> LogEntries { get; }
int? RequestLogExpirationDuration { get; set; }

View File

@@ -162,7 +162,8 @@ namespace WireMock.Owin
if (_options.MaxRequestLogCount != null)
{
foreach (var logEntry in _options.LogEntries.OrderBy(le => le.RequestMessage.DateTime).Take(_options.LogEntries.Count - _options.MaxRequestLogCount.Value).ToList())
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);
}
@@ -172,7 +173,7 @@ namespace WireMock.Owin
{
var checkTime = DateTime.UtcNow.AddHours(-_options.RequestLogExpirationDuration.Value);
foreach (var logEntry in _options.LogEntries.Where(le => le.RequestMessage.DateTime < checkTime).ToList())
foreach (var logEntry in _options.LogEntries.ToList().Where(le => le.RequestMessage.DateTime < checkTime))
{
_options.LogEntries.Remove(logEntry);
}

View File

@@ -27,7 +27,7 @@ namespace WireMock.Owin
public ConcurrentDictionary<string, ScenarioState> Scenarios { get; } = new ConcurrentDictionary<string, ScenarioState>();
public ObservableCollection<LogEntry> LogEntries { get; } = new ConcurrentObservableCollection<LogEntry>();
public ConcurrentObservableCollection<LogEntry> LogEntries { get; } = new ConcurrentObservableCollection<LogEntry>();
public int? RequestLogExpirationDuration { get; set; }