< prev index next >

src/java.httpclient/share/classes/java/net/http/MultiExchange.java

Print this page

        

*** 52,62 **** // Maximum number of times a request will be retried/redirected // for any reason final static int DEFAULT_MAX_ATTEMPTS = 5; final static int max_attempts = Utils.getIntegerNetProperty( ! "sun.net.httpclient.redirects.retrylimit", DEFAULT_MAX_ATTEMPTS ); private final List<HeaderFilter> filters; TimedEvent td; boolean cancelled = false; --- 52,62 ---- // Maximum number of times a request will be retried/redirected // for any reason final static int DEFAULT_MAX_ATTEMPTS = 5; final static int max_attempts = Utils.getIntegerNetProperty( ! "java.net.httpclient.redirects.retrylimit", DEFAULT_MAX_ATTEMPTS ); private final List<HeaderFilter> filters; TimedEvent td; boolean cancelled = false;
*** 185,196 **** } public CompletableFuture<HttpResponseImpl> responseAsync(Void v) { CompletableFuture<HttpResponseImpl> cf; if (++attempts > max_attempts) { ! cf = new CompletableFuture<>(); ! cf.completeExceptionally(new IOException("Too many retries")); } else { if (currentreq.timeval() != 0) { // set timer td = new TimedEvent(currentreq.timeval()); client.registerTimer(td); --- 185,195 ---- } public CompletableFuture<HttpResponseImpl> responseAsync(Void v) { CompletableFuture<HttpResponseImpl> cf; if (++attempts > max_attempts) { ! cf = CompletableFuture.failedFuture(new IOException("Too many retries")); } else { if (currentreq.timeval() != 0) { // set timer td = new TimedEvent(currentreq.timeval()); client.registerTimer(td);
*** 239,259 **** /** * Take a Throwable and return a suitable CompletableFuture that is * completed exceptionally. */ private CompletableFuture<HttpResponseImpl> getExceptionalCF(Throwable t) { - CompletableFuture<HttpResponseImpl> error = new CompletableFuture<>(); if ((t instanceof CompletionException) || (t instanceof ExecutionException)) { if (t.getCause() != null) { t = t.getCause(); } } if (cancelled && t instanceof IOException) { t = new HttpTimeoutException("request timed out"); } ! error.completeExceptionally(t); ! return error; } <T> T responseBody(HttpResponse.BodyProcessor<T> processor) { return getExchange().responseBody(processor); } --- 238,256 ---- /** * Take a Throwable and return a suitable CompletableFuture that is * completed exceptionally. */ private CompletableFuture<HttpResponseImpl> getExceptionalCF(Throwable t) { if ((t instanceof CompletionException) || (t instanceof ExecutionException)) { if (t.getCause() != null) { t = t.getCause(); } } if (cancelled && t instanceof IOException) { t = new HttpTimeoutException("request timed out"); } ! return CompletableFuture.failedFuture(t); } <T> T responseBody(HttpResponse.BodyProcessor<T> processor) { return getExchange().responseBody(processor); }
< prev index next >