Skip to content

Commit 10d4c49

Browse files
committed
Clean up
1 parent ca26340 commit 10d4c49

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/Servers/Kestrel/test/InMemory.FunctionalTests/KestrelMetricsTests.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -400,20 +400,24 @@ public async Task Http1Connection_ServerAbort_HasErrorType()
400400
var serviceContext = new TestServiceContext(LoggerFactory, metrics: new KestrelMetrics(testMeterFactory));
401401

402402
var sendString = "POST / HTTP/1.0\r\nContent-Length: 12\r\n\r\nHello World?";
403-
var readBodyTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
403+
var finishedSendingTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
404404

405405
await using var server = new TestServer(async c =>
406406
{
407407
await c.Request.Body.ReadUntilEndAsync();
408-
readBodyTcs.SetResult();
408+
409+
// An extra check to ensure that client is done sending before the server aborts.
410+
// This might not be necessary since we're reading to the end of the request body, but it doesn't hurt.
411+
await finishedSendingTcs.Task;
412+
409413
c.Abort();
410414
}, serviceContext);
411415

412416
using (var connection = server.CreateConnection())
413417
{
414418
await connection.Send(sendString).DefaultTimeout();
415419

416-
await readBodyTcs.Task.DefaultTimeout();
420+
finishedSendingTcs.SetResult();
417421

418422
await connection.ReceiveEnd().DefaultTimeout();
419423

0 commit comments

Comments
 (0)