You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@grails.apache.org by ja...@apache.org on 2026/03/03 17:44:31 UTC
(grails-core) 01/01: Fix flaky Ersatz empty response body test with @Retry
This is an automated email from the ASF dual-hosted git repository.
jamesfredley pushed a commit to branch fix/ersatz-roundtrip-connection-reset
in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 56663814ed92d531d5bc72776cea7c5e417114a2
Author: James Fredley <ja...@users.noreply.github.com>
AuthorDate: Tue Mar 3 12:44:15 2026 -0500
Fix flaky Ersatz empty response body test with @Retry
The 'ersatz mocks empty response body' test intermittently fails with
HttpClientException: Connection reset. This occurs because the Ersatz
server is recreated per test method on a fixed port (19876), and the
Micronaut @Client connection pool may hold stale connections from the
previous test's server instance.
Add @Retry(count = 2, delay = 200) scoped to HttpClientException so
only transient connection issues trigger a retry.
Assisted-by: Claude Code <Cl...@Claude.ai>
---
.../groovy/micronaut/MicronautErsatzRoundtripSpec.groovy | 2 ++
1 file changed, 2 insertions(+)
diff --git a/grails-test-examples/micronaut/src/integration-test/groovy/micronaut/MicronautErsatzRoundtripSpec.groovy b/grails-test-examples/micronaut/src/integration-test/groovy/micronaut/MicronautErsatzRoundtripSpec.groovy
index a5e2afffd5..a3b077bb4c 100644
--- a/grails-test-examples/micronaut/src/integration-test/groovy/micronaut/MicronautErsatzRoundtripSpec.groovy
+++ b/grails-test-examples/micronaut/src/integration-test/groovy/micronaut/MicronautErsatzRoundtripSpec.groovy
@@ -25,6 +25,7 @@ import io.micronaut.http.HttpResponse
import io.micronaut.http.MediaType
import io.micronaut.http.client.HttpClient
import spock.lang.AutoCleanup
+import spock.lang.Retry
import spock.lang.Specification
import org.springframework.beans.factory.annotation.Autowired
@@ -444,6 +445,7 @@ class MicronautErsatzRoundtripSpec extends Specification {
ersatz.verify()
}
+ @Retry(count = 2, delay = 200, exceptions = [io.micronaut.http.client.exceptions.HttpClientException])
void "full roundtrip: ersatz mocks empty response body"() {
given: 'ersatz mocks an endpoint returning 200 with an empty JSON object'
ersatz.expectations({ expect ->