Skip to content

Commit d38ca8c

Browse files
committed
Close intermediate 429 responses before retry to prevent resource leaks
When a request receives a 429 rate limit response and the client retries, the previous Response (and its underlying connection) was not being closed. This could leak connections from the OkHttp connection pool under sustained rate limiting. Close the response body before sleeping and retrying.
1 parent 526018f commit d38ca8c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

  • duo-client/src/main/java/com/duosecurity/client

duo-client/src/main/java/com/duosecurity/client/Http.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,10 @@ private Response executeRequest(Request request) throws Exception {
318318
return response;
319319
}
320320

321+
// Close the 429 response to release the connection back to the pool before retrying
322+
if (response.body() != null) {
323+
response.close();
324+
}
321325
sleep(backoffMs + nextRandomInt(1000));
322326
backoffMs *= BACKOFF_FACTOR;
323327
}

0 commit comments

Comments
 (0)