Skip to content

Commit 6e331ee

Browse files
bordingSimonCropp
andauthored
Fix audit forwarding when saga audit messages are enabled (#4904)
* fix null ref in Audit (#4894) fixes #4893 * Specify list capacity to avoid resizing * Use collection expression --------- Co-authored-by: Simon Cropp <[email protected]>
1 parent 99961d7 commit 6e331ee

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/ServiceControl.Audit/Auditing/AuditIngestor.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ public async Task Ingest(List<MessageContext> contexts, CancellationToken cancel
7070

7171
Task Forward(IReadOnlyCollection<MessageContext> messageContexts, string forwardingAddress, CancellationToken cancellationToken)
7272
{
73-
var transportOperations = new TransportOperation[messageContexts.Count]; //We could allocate based on the actual number of ProcessedMessages but this should be OK
74-
var index = 0;
73+
var transportOperations = new List<TransportOperation>(messageContexts.Count);
7574
MessageContext anyContext = null;
7675
foreach (var messageContext in messageContexts)
7776
{
@@ -90,13 +89,12 @@ Task Forward(IReadOnlyCollection<MessageContext> messageContexts, string forward
9089
// Forwarded messages should last as long as possible
9190
outgoingMessage.Headers.Remove(Headers.TimeToBeReceived);
9291

93-
transportOperations[index] = new TransportOperation(outgoingMessage, new UnicastAddressTag(forwardingAddress));
94-
index++;
92+
transportOperations.Add(new TransportOperation(outgoingMessage, new UnicastAddressTag(forwardingAddress)));
9593
}
9694

9795
return anyContext != null
9896
? messageDispatcher.Value.Dispatch(
99-
new TransportOperations(transportOperations),
97+
new TransportOperations([.. transportOperations]),
10098
anyContext.TransportTransaction, cancellationToken)
10199
: Task.CompletedTask;
102100
}

0 commit comments

Comments
 (0)