From 3665ee0d37a6004024626d09714d47fd287184fe Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Fri, 17 May 2013 11:01:28 +0000 Subject: [PATCH] Minor optimization git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1483735 13f79535-47bb-0310-9956-ffa450edef68 --- .../client/DefaultHttpRequestRetryHandler.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java index dfc894dbb..30233f7d5 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java @@ -113,13 +113,17 @@ public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler { // Do not retry if over max retry count return false; } - for (final Class rejectException : this.nonRetriableClasses) { - if (rejectException.isInstance(exception)) { - return false; + if (this.nonRetriableClasses.contains(exception.getClass())) { + return false; + } else { + for (final Class rejectException : this.nonRetriableClasses) { + if (rejectException.isInstance(exception)) { + return false; + } } } - final HttpClientContext localcontext = HttpClientContext.adapt(context); - final HttpRequest request = localcontext.getRequest(); + final HttpClientContext clientContext = HttpClientContext.adapt(context); + final HttpRequest request = clientContext.getRequest(); if(requestIsAborted(request)){ return false; @@ -130,7 +134,7 @@ public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler { return true; } - if (!localcontext.isRequestSent() || this.requestSentRetryEnabled) { + if (!clientContext.isRequestSent() || this.requestSentRetryEnabled) { // Retry if the request has not been sent fully or // if it's OK to retry methods that have been sent return true;