From 54586b69c52d0c32fbe649f86b9e231507d2060d Mon Sep 17 00:00:00 2001 From: Flavia Rainone Date: Tue, 17 Oct 2023 04:40:38 -0300 Subject: [PATCH] [UNDERTOW-2323] Update the test for handling special case where client gets a connection closed by goaway before processing the responses from server Signed-off-by: Flavia Rainone --- .../protocols/http2/RapidResetDDoSUnitTestCase.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/io/undertow/protocols/http2/RapidResetDDoSUnitTestCase.java b/core/src/test/java/io/undertow/protocols/http2/RapidResetDDoSUnitTestCase.java index 24480125e5..7b8f7b6674 100644 --- a/core/src/test/java/io/undertow/protocols/http2/RapidResetDDoSUnitTestCase.java +++ b/core/src/test/java/io/undertow/protocols/http2/RapidResetDDoSUnitTestCase.java @@ -241,7 +241,15 @@ public void assertDoSRstFramesHandled(int totalNumberOfRequests, int rstStreamLi latch.await(200, TimeUnit.SECONDS); - Assert.assertEquals(errorExpected? rstStreamLimit + 1:totalNumberOfRequests, responses.size()); + // server sent go away before processing and responding client frames, sometimes this happens, depends on the order of threads + // being executed + if (responses.isEmpty()) { + Assert.assertTrue(errorExpected); + Assert.assertNotNull(exception); + Assert.assertTrue(exception instanceof ClosedChannelException); + return; + } + Assert.assertEquals(errorExpected ? rstStreamLimit + 1 : totalNumberOfRequests, responses.size()); for (final ClientResponse response : responses) { final String responseBody = response.getAttachment(RESPONSE_BODY); Assert.assertTrue("Unexpected response body: " + responseBody, responseBody.isEmpty() || responseBody.equals(message));