Skip to content

Commit 38472c7

Browse files
Fix flaky test exception in HttpServerTest (#11164)
Fix flaky test exception by closing response in HttpServerTest DD_C0320J Co-authored-by: janhavis <janhavi.sahasrabuddhe@gmail.com> Close response body in redirect and blocking tests to prevent HTTP/2 flow control issues Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Re-add @flaky annotation on test exception until fix is verified in CI Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Merge branch 'master' into dd/fix/pekko-http-flaky-test-exception Co-authored-by: datadog-prod-us1-5[bot] <266081015+datadog-prod-us1-5[bot]@users.noreply.github.com> Co-authored-by: janhavi.sahasrabuddhe <janhavi.sahasrabuddhe@datadoghq.com>
1 parent 63343ba commit 38472c7

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

dd-java-agent/instrumentation-testing/src/main/groovy/datadog/trace/agent/test/base/HttpServerTest.groovy

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,6 +1170,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
11701170
}
11711171

11721172
response.body().contentLength() < 1 || redirectHasBody()
1173+
response.close()
11731174

11741175
and:
11751176
assertTraces(1) {
@@ -1210,6 +1211,8 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
12101211
if (bubblesResponse()) {
12111212
assert response.body().string().contains(ERROR.body)
12121213
assert response.code() == ERROR.status
1214+
} else {
1215+
response.close()
12131216
}
12141217

12151218
and:
@@ -1255,6 +1258,8 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
12551258
response.code() == EXCEPTION.status
12561259
if (testExceptionBody()) {
12571260
assert response.body().string() == EXCEPTION.body
1261+
} else {
1262+
response.close()
12581263
}
12591264

12601265
and:
@@ -1299,6 +1304,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
12991304

13001305
expect:
13011306
response.code() == NOT_FOUND.status
1307+
response.close()
13021308

13031309
and:
13041310
assertTraces(1) {
@@ -1836,6 +1842,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
18361842
response.code() == 301
18371843
response.header('location') == 'https://www.google.com/'
18381844
!handlerRan
1845+
response.close()
18391846

18401847
when:
18411848
TEST_WRITER.waitForTraces(1)
@@ -2117,6 +2124,7 @@ abstract class HttpServerTest<SERVER> extends WithHttpServer<SERVER> {
21172124
}
21182125
response.code() == 301
21192126
response.header("Location") == 'https://www.google.com/'
2127+
response.close()
21202128
TEST_WRITER.waitForTraces(1)
21212129
def trace = TEST_WRITER.get(0)
21222130

0 commit comments

Comments
 (0)