java.io.IOException: Retry limit exceeded at java.net.http.MultiExchange.response(java.httpclient@9-internal/MultiExchange.java:170) at java.net.http.HttpRequestImpl.response(java.httpclient@9-internal/HttpRequestImpl.java:257)

JDK Bug System | John Jiang | 8 months ago
tip
Your exception is missing from the Samebug knowledge base.
Here are the best solutions we found on the Internet.
Click on the to mark the helpful solution and get rewards for you help.
  1. 0

    Currently, property java.net.httpclient.redirects.retrylimit affects not only redirection limit, but also re-connection limit. That may be confusing. Redirection and re-connection have different meanings. Please consider the below test: import java.net.URI; import java.net.http.HttpClient; import java.net.http.HttpClient.Redirect; import java.net.http.HttpRequest; import java.net.http.HttpResponse; public class SimpleRedirectTest { public static void main(String[] args) throws Exception { System.setProperty("java.net.httpclient.redirects.retrylimit", "0"); String url = "..."; HttpClient client = HttpClient.create().followRedirects(Redirect.ALWAYS).build(); HttpRequest request = client.request(new URI(url)).GET(); HttpResponse<String> response = request.response(HttpResponse.BodyHandler.discard("BODY")); System.out.println(response.statusCode()); } } The test raises the following exception: Exception in thread "main" java.io.IOException: Retry limit exceeded at java.net.http.MultiExchange.response(java.httpclient@9-internal/MultiExchange.java:170) at java.net.http.HttpRequestImpl.response(java.httpclient@9-internal/HttpRequestImpl.java:257) at SimpleRedirectTest.main(SimpleRedirectTest.java:17) The exception is thrown while connecting the server, but the test only focus on redirection. It would be better use two different properties for redirection limit and re-connection limit.

    JDK Bug System | 8 months ago | John Jiang
    java.io.IOException: Retry limit exceeded at java.net.http.MultiExchange.response(java.httpclient@9-internal/MultiExchange.java:170) at java.net.http.HttpRequestImpl.response(java.httpclient@9-internal/HttpRequestImpl.java:257)

    Root Cause Analysis

    1. java.io.IOException

      Retry limit exceeded at java.net.http.MultiExchange.response(java.httpclient@9-internal/MultiExchange.java:170) at java.net.http.HttpRequestImpl.response(java.httpclient@9-internal/HttpRequestImpl.java:257)

      at SimpleRedirectTest.main()
    2. Unknown
      SimpleRedirectTest.main
      1. SimpleRedirectTest.main(SimpleRedirectTest.java:17)
      1 frame