# the backend fails its first 2 calls with 503; the gateway route retries up to 3 times
$ curl -i localhost:9091/flaky/reset
HTTP/1.1 200 OK
Content-type: application/json

{"reset":true}

$ curl -i localhost:8080/api/flaky?failFirst=2
HTTP/1.1 200 
Content-Type: application/json

{"call":3,"result":"ok"}

# how many calls did the backend actually see? (failFirst=0 just returns the counter)
$ curl -i localhost:9091/flaky?failFirst=0
HTTP/1.1 200 OK
Content-type: application/json

{"call":4,"result":"ok"}

# now a backend that never recovers: after the 3 retries the gateway gives up with a 500, not the backend's 503
$ curl -i localhost:9091/flaky/reset
HTTP/1.1 200 OK
Content-type: application/json

{"reset":true}

$ curl -i localhost:8080/api/flaky?failFirst=99
HTTP/1.1 500 
Content-Type: application/json

{"timestamp":"2026-11-25T19:22:37.164Z","status":500,"error":"Internal Server Error","path":"/api/flaky"}

# the backend saw the original try plus 3 retries = 4 calls, so the counter now reads 5
$ curl -i localhost:9091/flaky?failFirst=99
HTTP/1.1 503 Service Unavailable
Content-type: application/json

{"call":5,"result":"unavailable"}

# log line behind that 500:
Request processing failed: org.springframework.core.retry.RetryException: Retry policy for operation ... (FrameworkRetryFilterFunctions lambda)
# which retry implementation did the gateway pick? (DEBUG log at startup)
Retry filter selection: Spring Retry on classpath=false, useFrameworkRetry=false, selected filter=FrameworkRetryFilterFunctions
