mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-10-24 04:32:32 +00:00
Tests: the push recording handler survives the parallel fan-out
PushDeliveryService sends with Parallel.ForEachAsync, and RecordingHandler appended to plain lists without a lock: two concurrent sends could lose a request (Delivered 2, recorded 1), so Tenant_alert_also_reaches_platform_devices_whose_owners_home_tenant_it_is failed now and then (once in six full runs while it was traced). A request and its body are now recorded together under the lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -440,8 +440,13 @@ public class PushPairingServiceTests
|
||||
|
||||
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
|
||||
{
|
||||
Requests.Add(request);
|
||||
Bodies.Add(request.Content == null ? Array.Empty<byte>() : await request.Content.ReadAsByteArrayAsync(cancellationToken));
|
||||
var body = request.Content == null ? Array.Empty<byte>() : await request.Content.ReadAsByteArrayAsync(cancellationToken);
|
||||
// PushDeliveryService fans out in parallel: an unguarded List.Add loses entries.
|
||||
lock (Requests)
|
||||
{
|
||||
Requests.Add(request);
|
||||
Bodies.Add(body);
|
||||
}
|
||||
return new HttpResponseMessage(Respond(request)) { Content = new StringContent(string.Empty) };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user