From 3d34035b1749efb0e27a1d5089942d9c97148524 Mon Sep 17 00:00:00 2001 From: Oleg Kalnichevski Date: Tue, 15 Jan 2013 20:08:10 +0000 Subject: [PATCH] Fixed style check violations (tabs introduced by a previous commit) git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1433610 13f79535-47bb-0310-9956-ffa450edef68 --- .../impl/client/cache/BasicHttpCache.java | 28 ++-- .../impl/client/cache/CacheInvalidator.java | 48 +++--- .../impl/client/cache/CacheKeyGenerator.java | 12 +- .../client/cache/CacheValidityPolicy.java | 44 +++--- .../cache/CachedHttpResponseGenerator.java | 4 +- .../CachedResponseSuitabilityChecker.java | 32 ++-- .../http/impl/client/cache/CachingExec.java | 36 ++--- .../impl/client/cache/CachingHttpClient.java | 44 +++--- .../cache/RequestProtocolCompliance.java | 16 +- .../client/cache/ResponseCachingPolicy.java | 52 +++---- .../cache/ResponseProtocolCompliance.java | 32 ++-- .../http/impl/client/cache/WarningValue.java | 32 ++-- .../memcached/MemcachedHttpCacheStorage.java | 28 ++-- .../http/impl/client/cache/HttpTestUtils.java | 38 ++--- .../impl/client/cache/RequestEquivalent.java | 4 +- .../impl/client/cache/TestCachingExec.java | 4 +- .../cache/TestHttpCacheEntrySerializers.java | 28 ++-- .../cache/TestProtocolRequirements.java | 56 +++---- .../TestMemcachedHttpCacheStorage.java | 4 +- .../apache/http/auth/BasicUserPrincipal.java | 4 +- .../org/apache/http/auth/NTCredentials.java | 4 +- .../org/apache/http/auth/NTUserPrincipal.java | 4 +- .../auth/UsernamePasswordCredentials.java | 4 +- .../apache/http/client/utils/Rfc3492Idn.java | 36 ++--- .../apache/http/conn/BasicManagedEntity.java | 4 +- .../http/conn/EofSensorInputStream.java | 24 +-- .../conn/MultihomePlainSocketFactory.java | 10 +- .../http/conn/routing/BasicRouteDirector.java | 68 ++++----- .../apache/http/conn/routing/HttpRoute.java | 40 ++--- .../http/conn/routing/RouteTracker.java | 40 ++--- .../org/apache/http/conn/scheme/Scheme.java | 4 +- .../scheme/SchemeSocketFactoryAdaptor.java | 8 +- .../conn/scheme/SocketFactoryAdaptor.java | 8 +- .../apache/http/impl/auth/GGSSchemeBase.java | 12 +- .../apache/http/impl/auth/NTLMEngineImpl.java | 142 +++++++++--------- .../http/impl/client/AIMDBackoffManager.java | 16 +- .../http/impl/client/AbstractHttpClient.java | 8 +- .../impl/client/DecompressingHttpClient.java | 8 +- .../impl/client/DefaultRequestDirector.java | 4 +- .../impl/conn/AbstractClientConnAdapter.java | 20 +-- .../impl/conn/AbstractPooledConnAdapter.java | 8 +- .../impl/conn/DefaultClientConnection.java | 4 +- .../impl/conn/DefaultHttpRoutePlanner.java | 4 +- .../impl/conn/ProxySelectorRoutePlanner.java | 12 +- .../impl/conn/SingleClientConnManager.java | 38 ++--- .../impl/conn/tsccm/AbstractConnPool.java | 4 +- .../http/impl/conn/tsccm/ConnPoolByRoute.java | 4 +- .../impl/conn/tsccm/RouteSpecificPool.java | 8 +- .../tsccm/ThreadSafeClientConnManager.java | 4 +- .../http/impl/conn/tsccm/WaitingThread.java | 8 +- .../impl/conn/tsccm/WaitingThreadAborter.java | 8 +- .../apache/http/impl/cookie/DateUtils.java | 4 +- .../http/impl/cookie/PublicSuffixFilter.java | 28 ++-- .../impl/cookie/PublicSuffixListParser.java | 38 ++--- .../impl/execchain/BackoffStrategyExec.java | 12 +- .../java/org/apache/http/conn/TestScheme.java | 20 +-- .../http/conn/routing/TestRouteTracker.java | 4 +- .../http/impl/auth/TestNTLMEngineImpl.java | 12 +- .../impl/client/TestAIMDBackoffManager.java | 8 +- .../client/TestDecompressingHttpClient.java | 8 +- .../client/TestDefaultBackoffStrategy.java | 4 +- .../client/integration/TestAbortHandling.java | 24 +-- .../integration/TestConnectionManagement.java | 36 ++--- .../apache/http/localserver/EchoHandler.java | 4 +- .../http/localserver/LocalTestServer.java | 8 +- 65 files changed, 661 insertions(+), 661 deletions(-) diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java index f2606e5d6..68a8bc425 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/BasicHttpCache.java @@ -162,8 +162,8 @@ class BasicHttpCache implements HttpCache { } Header hdr = resp.getFirstHeader(HTTP.CONTENT_LEN); if (hdr == null) { - return false; - } + return false; + } int contentLength; try { contentLength = Integer.parseInt(hdr.getValue()); @@ -284,15 +284,15 @@ class BasicHttpCache implements HttpCache { public HttpCacheEntry getCacheEntry(final HttpHost host, final HttpRequest request) throws IOException { HttpCacheEntry root = storage.getEntry(uriExtractor.getURI(host, request)); if (root == null) { - return null; - } + return null; + } if (!root.hasVariants()) { - return root; - } + return root; + } String variantCacheKey = root.getVariantMap().get(uriExtractor.getVariantKey(request, root)); if (variantCacheKey == null) { - return null; - } + return null; + } return storage.getEntry(variantCacheKey); } @@ -306,8 +306,8 @@ class BasicHttpCache implements HttpCache { Map variants = new HashMap(); HttpCacheEntry root = storage.getEntry(uriExtractor.getURI(host, request)); if (root == null || !root.hasVariants()) { - return variants; - } + return variants; + } for(Map.Entry variant : root.getVariantMap().entrySet()) { String variantKey = variant.getKey(); String variantCacheKey = variant.getValue(); @@ -321,12 +321,12 @@ class BasicHttpCache implements HttpCache { throws IOException { HttpCacheEntry entry = storage.getEntry(variantCacheKey); if (entry == null) { - return; - } + return; + } Header etagHeader = entry.getFirstHeader(HeaderConstants.ETAG); if (etagHeader == null) { - return; - } + return; + } variants.put(etagHeader.getValue(), new Variant(variantKey, variantCacheKey, entry)); } diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java index db3996f7c..3caf6619c 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheInvalidator.java @@ -135,8 +135,8 @@ class CacheInvalidator { protected void flushUriIfSameHost(final URL requestURL, final URL targetURL) { URL canonicalTarget = getAbsoluteURL(cacheKeyGenerator.canonicalizeUri(targetURL.toString())); if (canonicalTarget == null) { - return; - } + return; + } if (canonicalTarget.getAuthority().equalsIgnoreCase(requestURL.getAuthority())) { flushEntry(canonicalTarget.toString()); } @@ -145,8 +145,8 @@ class CacheInvalidator { protected void flushRelativeUriFromSameHost(final URL reqURL, final String relUri) { URL relURL = getRelativeURL(reqURL, relUri); if (relURL == null) { - return; - } + return; + } flushUriIfSameHost(reqURL, relURL); } @@ -154,8 +154,8 @@ class CacheInvalidator { protected boolean flushAbsoluteUriFromSameHost(final URL reqURL, final String uri) { URL absURL = getAbsoluteURL(uri); if (absURL == null) { - return false; - } + return false; + } flushUriIfSameHost(reqURL,absURL); return true; } @@ -197,31 +197,31 @@ class CacheInvalidator { final HttpRequest request, final HttpResponse response) { int status = response.getStatusLine().getStatusCode(); if (status < 200 || status > 299) { - return; - } + return; + } URL reqURL = getAbsoluteURL(cacheKeyGenerator.getURI(host, request)); if (reqURL == null) { - return; - } + return; + } URL canonURL = getContentLocationURL(reqURL, response); if (canonURL == null) { - return; - } + return; + } String cacheKey = cacheKeyGenerator.canonicalizeUri(canonURL.toString()); HttpCacheEntry entry = getEntry(cacheKey); if (entry == null) { - return; - } + return; + } // do not invalidate if response is strictly older than entry // or if the etags match if (responseDateOlderThanEntryDate(response, entry)) { - return; - } + return; + } if (!responseAndEntryEtagsDiffer(response, entry)) { - return; - } + return; + } flushUriIfSameHost(reqURL, canonURL); } @@ -229,13 +229,13 @@ class CacheInvalidator { private URL getContentLocationURL(final URL reqURL, final HttpResponse response) { Header clHeader = response.getFirstHeader("Content-Location"); if (clHeader == null) { - return null; - } + return null; + } String contentLocation = clHeader.getValue(); URL canonURL = getAbsoluteURL(contentLocation); if (canonURL != null) { - return canonURL; - } + return canonURL; + } return getRelativeURL(reqURL, contentLocation); } @@ -244,8 +244,8 @@ class CacheInvalidator { Header entryEtag = entry.getFirstHeader(HeaderConstants.ETAG); Header responseEtag = response.getFirstHeader(HeaderConstants.ETAG); if (entryEtag == null || responseEtag == null) { - return false; - } + return false; + } return (!entryEtag.getValue().equals(responseEtag.getValue())); } diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java index 93746b80a..9089e9348 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheKeyGenerator.java @@ -75,8 +75,8 @@ class CacheKeyGenerator { int port = canonicalizePort(u.getPort(), protocol); String path = canonicalizePath(u.getPath()); if ("".equals(path)) { - path = "/"; - } + path = "/"; + } String query = u.getQuery(); String file = (query != null) ? (path + "?" + query) : path; URL out = new URL(protocol, hostname, port, file); @@ -112,8 +112,8 @@ class CacheKeyGenerator { protected String getFullHeaderValue(final Header[] headers) { if (headers == null) { - return ""; - } + return ""; + } StringBuilder buf = new StringBuilder(""); boolean first = true; @@ -140,8 +140,8 @@ class CacheKeyGenerator { */ public String getVariantURI(final HttpHost host, final HttpRequest req, final HttpCacheEntry entry) { if (!entry.hasVariants()) { - return getURI(host, req); - } + return getURI(host, req); + } return getVariantKey(req, entry) + getURI(host, req); } diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java index be672472f..a1cbb7894 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CacheValidityPolicy.java @@ -57,18 +57,18 @@ class CacheValidityPolicy { public long getFreshnessLifetimeSecs(final HttpCacheEntry entry) { long maxage = getMaxAge(entry); if (maxage > -1) { - return maxage; - } + return maxage; + } Date dateValue = getDateValue(entry); if (dateValue == null) { - return 0L; - } + return 0L; + } Date expiry = getExpirationDate(entry); if (expiry == null) { - return 0; - } + return 0; + } long diff = expiry.getTime() - dateValue.getTime(); return (diff / 1000); } @@ -103,8 +103,8 @@ class CacheValidityPolicy { if (dateValue != null && lastModifiedValue != null) { long diff = dateValue.getTime() - lastModifiedValue.getTime(); if (diff < 0) { - return 0; - } + return 0; + } return (long)(coefficient * (diff / 1000)); } @@ -175,8 +175,8 @@ class CacheValidityPolicy { protected Date getDateValue(final HttpCacheEntry entry) { Header dateHdr = entry.getFirstHeader(HTTP.DATE_HEADER); if (dateHdr == null) { - return null; - } + return null; + } try { return DateUtils.parseDate(dateHdr.getValue()); } catch (DateParseException dpe) { @@ -188,8 +188,8 @@ class CacheValidityPolicy { protected Date getLastModifiedValue(final HttpCacheEntry entry) { Header dateHdr = entry.getFirstHeader(HeaderConstants.LAST_MODIFIED); if (dateHdr == null) { - return null; - } + return null; + } try { return DateUtils.parseDate(dateHdr.getValue()); } catch (DateParseException dpe) { @@ -201,8 +201,8 @@ class CacheValidityPolicy { protected long getContentLengthValue(final HttpCacheEntry entry) { Header cl = entry.getFirstHeader(HTTP.CONTENT_LEN); if (cl == null) { - return -1; - } + return -1; + } try { return Long.parseLong(cl.getValue()); @@ -229,12 +229,12 @@ class CacheValidityPolicy { protected long getApparentAgeSecs(final HttpCacheEntry entry) { Date dateValue = getDateValue(entry); if (dateValue == null) { - return MAX_AGE; - } + return MAX_AGE; + } long diff = entry.getResponseDate().getTime() - dateValue.getTime(); if (diff < 0L) { - return 0; - } + return 0; + } return (diff / 1000); } @@ -299,8 +299,8 @@ class CacheValidityPolicy { protected Date getExpirationDate(final HttpCacheEntry entry) { Header expiresHeader = entry.getFirstHeader(HeaderConstants.EXPIRES); if (expiresHeader == null) { - return null; - } + return null; + } try { return DateUtils.parseDate(expiresHeader.getValue()); } catch (DateParseException dpe) { @@ -325,8 +325,8 @@ class CacheValidityPolicy { long age = getCurrentAgeSecs(entry, now); long freshness = getFreshnessLifetimeSecs(entry); if (age <= freshness) { - return 0L; - } + return 0L; + } return (age - freshness); } diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java index 93c660805..c9e6df291 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedHttpResponseGenerator.java @@ -152,8 +152,8 @@ class CachedHttpResponseGenerator { private void addMissingContentLengthHeader(final HttpResponse response, final HttpEntity entity) { if (transferEncodingIsPresent(response)) { - return; - } + return; + } Header contentLength = response.getFirstHeader(HTTP.CONTENT_LEN); if (contentLength == null) { diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java index cec51345f..4792ee21f 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachedResponseSuitabilityChecker.java @@ -74,29 +74,29 @@ class CachedResponseSuitabilityChecker { private boolean isFreshEnough(final HttpCacheEntry entry, final HttpRequest request, final Date now) { if (validityStrategy.isResponseFresh(entry, now)) { - return true; - } + return true; + } if (useHeuristicCaching && validityStrategy.isResponseHeuristicallyFresh(entry, now, heuristicCoefficient, heuristicDefaultLifetime)) { - return true; - } + return true; + } if (originInsistsOnFreshness(entry)) { - return false; - } + return false; + } long maxstale = getMaxStale(request); if (maxstale == -1) { - return false; - } + return false; + } return (maxstale > validityStrategy.getStalenessSecs(entry, now)); } private boolean originInsistsOnFreshness(final HttpCacheEntry entry) { if (validityStrategy.mustRevalidate(entry)) { - return true; - } + return true; + } if (!sharedCache) { - return false; - } + return false; + } return validityStrategy.proxyRevalidate(entry) || validityStrategy.hasCacheControlDirective(entry, "s-maxage"); } @@ -113,8 +113,8 @@ class CachedResponseSuitabilityChecker { try { long val = Long.parseLong(elt.getValue()); if (val < 0) { - val = 0; - } + val = 0; + } if (maxstale == -1 || val < maxstale) { maxstale = val; } @@ -212,8 +212,8 @@ class CachedResponseSuitabilityChecker { try { long minfresh = Long.parseLong(elt.getValue()); if (minfresh < 0L) { - return false; - } + return false; + } long age = validityStrategy.getCurrentAgeSecs(entry, now); long freshness = validityStrategy.getFreshnessLifetimeSecs(entry); if (freshness - age < minfresh) { diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java index 5ddbb9c16..9e4403c6d 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingExec.java @@ -487,8 +487,8 @@ public class CachingExec implements ClientExecChain { long age = validityPolicy.getCurrentAgeSecs(entry, now); long lifetime = validityPolicy.getFreshnessLifetimeSecs(entry); if (age - lifetime > maxstale) { - return true; - } + return true; + } } catch (NumberFormatException nfe) { return true; } @@ -506,8 +506,8 @@ public class CachingExec implements ClientExecChain { final ProtocolVersion pv = msg.getProtocolVersion(); String existingEntry = viaHeaders.get(pv); if (existingEntry != null) { - return existingEntry; - } + return existingEntry; + } final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; @@ -549,16 +549,16 @@ public class CachingExec implements ClientExecChain { RequestLine line = request.getRequestLine(); if (!HeaderConstants.OPTIONS_METHOD.equals(line.getMethod())) { - return false; - } + return false; + } if (!"*".equals(line.getUri())) { - return false; - } + return false; + } if (!"0".equals(request.getFirstHeader(HeaderConstants.MAX_FORWARDS).getValue())) { - return false; - } + return false; + } return true; } @@ -595,8 +595,8 @@ public class CachingExec implements ClientExecChain { Date entryDate = DateUtils.parseDate(entryDateHeader.getValue()); Date respDate = DateUtils.parseDate(responseDateHeader.getValue()); if (respDate.before(entryDate)) { - return true; - } + return true; + } } catch (DateParseException e) { // either backend response or cached entry did not have a valid // Date header, so we can't tell if they are out of order @@ -853,16 +853,16 @@ public class CachingExec implements ClientExecChain { // nop } if (existing == null) { - return false; - } + return false; + } Header entryDateHeader = existing.getFirstHeader(HTTP.DATE_HEADER); if (entryDateHeader == null) { - return false; - } + return false; + } Header responseDateHeader = backendResponse.getFirstHeader(HTTP.DATE_HEADER); if (responseDateHeader == null) { - return false; - } + return false; + } try { Date entryDate = DateUtils.parseDate(entryDateHeader.getValue()); Date responseDate = DateUtils.parseDate(responseDateHeader.getValue()); diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java index 7a18823bf..aeb2feb70 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/CachingHttpClient.java @@ -433,8 +433,8 @@ public class CachingHttpClient implements HttpClient { HttpResponse fatalErrorResponse = getFatallyNoncompliantResponse( request, context); if (fatalErrorResponse != null) { - return fatalErrorResponse; - } + return fatalErrorResponse; + } requestCompliance.makeRequestCompliant(request); request.addHeader("Via",via); @@ -654,8 +654,8 @@ public class CachingHttpClient implements HttpClient { long age = validityPolicy.getCurrentAgeSecs(entry, now); long lifetime = validityPolicy.getFreshnessLifetimeSecs(entry); if (age - lifetime > maxstale) { - return true; - } + return true; + } } catch (NumberFormatException nfe) { return true; } @@ -673,8 +673,8 @@ public class CachingHttpClient implements HttpClient { final ProtocolVersion pv = msg.getProtocolVersion(); String existingEntry = viaHeaders.get(pv); if (existingEntry != null) { - return existingEntry; - } + return existingEntry; + } final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader()); final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; @@ -727,16 +727,16 @@ public class CachingHttpClient implements HttpClient { RequestLine line = request.getRequestLine(); if (!HeaderConstants.OPTIONS_METHOD.equals(line.getMethod())) { - return false; - } + return false; + } if (!"*".equals(line.getUri())) { - return false; - } + return false; + } if (!"0".equals(request.getFirstHeader(HeaderConstants.MAX_FORWARDS).getValue())) { - return false; - } + return false; + } return true; } @@ -763,8 +763,8 @@ public class CachingHttpClient implements HttpClient { Date entryDate = DateUtils.parseDate(entryDateHeader.getValue()); Date respDate = DateUtils.parseDate(responseDateHeader.getValue()); if (respDate.before(entryDate)) { - return true; - } + return true; + } } catch (DateParseException e) { // either backend response or cached entry did not have a valid // Date header, so we can't tell if they are out of order @@ -910,8 +910,8 @@ public class CachingHttpClient implements HttpClient { cachedResponse.addHeader(HeaderConstants.WARNING, "110 localhost \"Response is stale\""); HttpEntity errorBody = backendResponse.getEntity(); if (errorBody != null) { - EntityUtils.consume(errorBody); - } + EntityUtils.consume(errorBody); + } return cachedResponse; } @@ -985,16 +985,16 @@ public class CachingHttpClient implements HttpClient { // nop } if (existing == null) { - return false; - } + return false; + } Header entryDateHeader = existing.getFirstHeader(HTTP.DATE_HEADER); if (entryDateHeader == null) { - return false; - } + return false; + } Header responseDateHeader = backendResponse.getFirstHeader(HTTP.DATE_HEADER); if (responseDateHeader == null) { - return false; - } + return false; + } try { Date entryDate = DateUtils.parseDate(entryDateHeader.getValue()); Date responseDate = DateUtils.parseDate(responseDateHeader.getValue()); diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java index 73e31210e..bedb246e5 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/RequestProtocolCompliance.java @@ -126,8 +126,8 @@ class RequestProtocolCompliance { } } if (!shouldStrip) { - return; - } + return; + } request.removeHeaders(HeaderConstants.CACHE_CONTROL); request.setHeader(HeaderConstants.CACHE_CONTROL, buildHeaderFromElements(outElts)); } @@ -304,13 +304,13 @@ class RequestProtocolCompliance { Header range = request.getFirstHeader(HeaderConstants.RANGE); if (range == null) { - return null; - } + return null; + } Header ifRange = request.getFirstHeader(HeaderConstants.IF_RANGE); if (ifRange == null) { - return null; - } + return null; + } String val = ifRange.getValue(); if (val.startsWith("W/")) { @@ -338,8 +338,8 @@ class RequestProtocolCompliance { } else { Header ifNoneMatch = request.getFirstHeader(HeaderConstants.IF_NONE_MATCH); if (ifNoneMatch == null) { - return null; - } + return null; + } String val2 = ifNoneMatch.getValue(); if (val2.startsWith("W/")) { diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java index dbdd04269..741a5a7b1 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseCachingPolicy.java @@ -116,27 +116,27 @@ class ResponseCachingPolicy { if (contentLength != null) { int contentLengthValue = Integer.parseInt(contentLength.getValue()); if (contentLengthValue > this.maxObjectSizeBytes) { - return false; - } + return false; + } } Header[] ageHeaders = response.getHeaders(HeaderConstants.AGE); if (ageHeaders.length > 1) { - return false; - } + return false; + } Header[] expiresHeaders = response.getHeaders(HeaderConstants.EXPIRES); if (expiresHeaders.length > 1) { - return false; - } + return false; + } Header[] dateHeaders = response.getHeaders(HTTP.DATE_HEADER); if (dateHeaders.length != 1) { - return false; - } + return false; + } try { DateUtils.parseDate(dateHeaders[0].getValue()); @@ -153,28 +153,28 @@ class ResponseCachingPolicy { } if (isExplicitlyNonCacheable(response)) { - return false; - } + return false; + } return (cacheable || isExplicitlyCacheable(response)); } private boolean unknownStatusCode(final int status) { if (status >= 100 && status <= 101) { - return false; - } + return false; + } if (status >= 200 && status <= 206) { - return false; - } + return false; + } if (status >= 300 && status <= 307) { - return false; - } + return false; + } if (status >= 400 && status <= 417) { - return false; - } + return false; + } if (status >= 500 && status <= 505) { - return false; - } + return false; + } return true; } @@ -208,8 +208,8 @@ class ResponseCachingPolicy { protected boolean isExplicitlyCacheable(final HttpResponse response) { if (response.getFirstHeader(HeaderConstants.EXPIRES) != null) { - return true; - } + return true; + } String[] cacheableParams = { HeaderConstants.CACHE_CONTROL_MAX_AGE, "s-maxage", HeaderConstants.CACHE_CONTROL_MUST_REVALIDATE, HeaderConstants.CACHE_CONTROL_PROXY_REVALIDATE, @@ -268,13 +268,13 @@ class ResponseCachingPolicy { private boolean expiresHeaderLessOrEqualToDateHeaderAndNoCacheControl( final HttpResponse response) { if (response.getFirstHeader(HeaderConstants.CACHE_CONTROL) != null) { - return false; - } + return false; + } Header expiresHdr = response.getFirstHeader(HeaderConstants.EXPIRES); Header dateHdr = response.getFirstHeader(HTTP.DATE_HEADER); if (expiresHdr == null || dateHdr == null) { - return false; - } + return false; + } try { Date expires = DateUtils.parseDate(expiresHdr.getValue()); Date date = DateUtils.parseDate(dateHdr.getValue()); diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java index 4c591414c..cc78faec0 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ResponseProtocolCompliance.java @@ -95,8 +95,8 @@ class ResponseProtocolCompliance { private void consumeBody(final HttpResponse response) throws IOException { HttpEntity body = response.getEntity(); if (body != null) { - EntityUtils.consume(body); - } + EntityUtils.consume(body); + } } private void warningsWithNonMatchingWarnDatesAreRemoved( @@ -109,14 +109,14 @@ class ResponseProtocolCompliance { } if (responseDate == null) { - return; - } + return; + } Header[] warningHeaders = response.getHeaders(HeaderConstants.WARNING); if (warningHeaders == null || warningHeaders.length == 0) { - return; - } + return; + } List
newWarningHeaders = new ArrayList
(); boolean modified = false; @@ -141,8 +141,8 @@ class ResponseProtocolCompliance { private void identityIsNotUsedInContentEncoding(final HttpResponse response) { Header[] hdrs = response.getHeaders(HTTP.CONTENT_ENCODING); if (hdrs == null || hdrs.length == 0) { - return; - } + return; + } List
newHeaders = new ArrayList
(); boolean modified = false; for (Header h : hdrs) { @@ -153,8 +153,8 @@ class ResponseProtocolCompliance { modified = true; } else { if (!first) { - buf.append(","); - } + buf.append(","); + } buf.append(elt.toString()); first = false; } @@ -165,8 +165,8 @@ class ResponseProtocolCompliance { } } if (!modified) { - return; - } + return; + } response.removeHeaders(HTTP.CONTENT_ENCODING); for (Header h : newHeaders) { response.addHeader(h); @@ -184,8 +184,8 @@ class ResponseProtocolCompliance { final HttpResponse response) throws IOException { if (request.getFirstHeader(HeaderConstants.RANGE) != null || response.getStatusLine().getStatusCode() != HttpStatus.SC_PARTIAL_CONTENT) { - return; - } + return; + } consumeBody(response); throw new ClientProtocolException(UNEXPECTED_PARTIAL_CONTENT); @@ -234,8 +234,8 @@ class ResponseProtocolCompliance { HttpRequest originalRequest = request.getOriginal(); if (originalRequest instanceof HttpEntityEnclosingRequest) { if (((HttpEntityEnclosingRequest)originalRequest).expectContinue()) { - return; - } + return; + } } consumeBody(response); throw new ClientProtocolException(UNEXPECTED_100_CONTINUE); diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/WarningValue.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/WarningValue.java index a1c545eee..ae03e9760 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/WarningValue.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/WarningValue.java @@ -81,8 +81,8 @@ class WarningValue { } catch (IllegalArgumentException e) { final int nextComma = src.indexOf(',', offs); if (nextComma == -1) { - break; - } + break; + } offs = nextComma + 1; } } @@ -152,12 +152,12 @@ class WarningValue { */ protected void consumeToken() { if (!isTokenChar(src.charAt(offs))) { - parseError(); - } + parseError(); + } while(offs < src.length()) { if (!isTokenChar(src.charAt(offs))) { - break; - } + break; + } offs++; } } @@ -178,11 +178,11 @@ class WarningValue { protected void consumeHostPort() { Matcher m = HOSTPORT_PATTERN.matcher(src.substring(offs)); if (!m.find()) { - parseError(); - } + parseError(); + } if (m.start() != 0) { - parseError(); - } + parseError(); + } offs += m.end(); } @@ -212,8 +212,8 @@ class WarningValue { */ protected void consumeQuotedString() { if (src.charAt(offs) != '\"') { - parseError(); - } + parseError(); + } offs++; boolean foundEnd = false; while(offs < src.length() && !foundEnd) { @@ -231,8 +231,8 @@ class WarningValue { } } if (!foundEnd) { - parseError(); - } + parseError(); + } } /* @@ -265,8 +265,8 @@ class WarningValue { int curr = offs; Matcher m = WARN_DATE_PATTERN.matcher(src.substring(offs)); if (!m.lookingAt()) { - parseError(); - } + parseError(); + } offs += m.end(); try { warnDate = DateUtils.parseDate(src.substring(curr+1,offs-1)); diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java index b74c072d5..614fa743e 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/MemcachedHttpCacheStorage.java @@ -162,8 +162,8 @@ public class MemcachedHttpCacheStorage implements HttpCacheStorage { byte[] bytes = serializeEntry(url, entry); String key = getCacheKey(url); if (key == null) { - return; - } + return; + } try { client.set(key, 0, bytes); } catch (OperationTimeoutException ex) { @@ -192,8 +192,8 @@ public class MemcachedHttpCacheStorage implements HttpCacheStorage { private byte[] convertToByteArray(final Object o) { if (o == null) { - return null; - } + return null; + } if (!(o instanceof byte[])) { log.warn("got a non-bytearray back from memcached: " + o); return null; @@ -204,8 +204,8 @@ public class MemcachedHttpCacheStorage implements HttpCacheStorage { private MemcachedCacheEntry reconstituteEntry(final Object o) throws IOException { byte[] bytes = convertToByteArray(o); if (bytes == null) { - return null; - } + return null; + } MemcachedCacheEntry mce = memcachedCacheEntryFactory.getUnsetCacheEntry(); try { mce.set(bytes); @@ -218,13 +218,13 @@ public class MemcachedHttpCacheStorage implements HttpCacheStorage { public HttpCacheEntry getEntry(final String url) throws IOException { String key = getCacheKey(url); if (key == null) { - return null; - } + return null; + } try { MemcachedCacheEntry mce = reconstituteEntry(client.get(key)); if (mce == null || !url.equals(mce.getStorageKey())) { - return null; - } + return null; + } return mce.getHttpCacheEntry(); } catch (OperationTimeoutException ex) { throw new MemcachedOperationTimeoutException(ex); @@ -234,8 +234,8 @@ public class MemcachedHttpCacheStorage implements HttpCacheStorage { public void removeEntry(final String url) throws IOException { String key = getCacheKey(url); if (key == null) { - return; - } + return; + } try { client.delete(key); } catch (OperationTimeoutException ex) { @@ -273,8 +273,8 @@ public class MemcachedHttpCacheStorage implements HttpCacheStorage { if (casResult != CASResponse.OK) { numRetries++; } else { - return; - } + return; + } } } catch (OperationTimeoutException ex) { throw new MemcachedOperationTimeoutException(ex); diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/HttpTestUtils.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/HttpTestUtils.java index 511a5befb..bfdea738c 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/HttpTestUtils.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/HttpTestUtils.java @@ -97,8 +97,8 @@ public class HttpTestUtils { public static boolean isHopByHopHeader(final String name) { for (String s : HOP_BY_HOP_HEADERS) { if (s.equalsIgnoreCase(name)) { - return true; - } + return true; + } } return false; } @@ -109,8 +109,8 @@ public class HttpTestUtils { public static boolean isMultiHeader(final String name) { for (String s : MULTI_HEADERS) { if (s.equalsIgnoreCase(name)) { - return true; - } + return true; + } } return false; } @@ -121,8 +121,8 @@ public class HttpTestUtils { public static boolean isSingleHeader(final String name) { for (String s : SINGLE_HEADERS) { if (s.equalsIgnoreCase(name)) { - return true; - } + return true; + } } return false; } @@ -133,17 +133,17 @@ public class HttpTestUtils { InputStream i1 = e1.getContent(); InputStream i2 = e2.getContent(); if (i1 == null && i2 == null) { - return true; - } + return true; + } if (i1 == null || i2 == null) - { - return false; // avoid possible NPEs below - } + { + return false; // avoid possible NPEs below + } int b1 = -1; while ((b1 = i1.read()) != -1) { if (b1 != i2.read()) { - return false; - } + return false; + } } return (-1 == i2.read()); } @@ -207,8 +207,8 @@ public class HttpTestUtils { String r1val = getCanonicalHeaderValue(r1, h.getName()); String r2val = getCanonicalHeaderValue(r2, h.getName()); if (!r1val.equals(r2val)) { - return false; - } + return false; + } } } return true; @@ -227,12 +227,12 @@ public class HttpTestUtils { throws Exception { final boolean entitiesEquivalent = equivalent(r1.getEntity(), r2.getEntity()); if (!entitiesEquivalent) { - return false; - } + return false; + } final boolean statusLinesEquivalent = semanticallyTransparent(r1.getStatusLine(), r2.getStatusLine()); if (!statusLinesEquivalent) { - return false; - } + return false; + } final boolean e2eHeadersEquivalentSubset = isEndToEndHeaderSubset( r1, r2); return e2eHeadersEquivalentSubset; diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/RequestEquivalent.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/RequestEquivalent.java index 4022008e1..282ce49ff 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/RequestEquivalent.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/RequestEquivalent.java @@ -39,8 +39,8 @@ public class RequestEquivalent implements IArgumentMatcher { public boolean matches(final Object actual) { if (!(actual instanceof HttpRequest)) { - return false; - } + return false; + } HttpRequest other = (HttpRequest) actual; return HttpTestUtils.equivalent(expected, other); } diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java index 5788189a7..34782a8d6 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingExec.java @@ -1414,8 +1414,8 @@ public class TestCachingExec { @Override public int read() throws IOException { if (closed) { - throw new SocketException("Socket closed"); - } + throw new SocketException("Socket closed"); + } throw new SocketTimeoutException("Read timed out"); } }, 128)); diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheEntrySerializers.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheEntrySerializers.java index 747764caa..a2afa7f4d 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheEntrySerializers.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestHttpCacheEntrySerializers.java @@ -103,35 +103,35 @@ public class TestHttpCacheEntrySerializers { // dates are only stored with second precision, so scrub milliseconds if (!((one.getRequestDate().getTime() / 1000) == (two.getRequestDate() .getTime() / 1000))) { - return false; - } + return false; + } if (!((one.getResponseDate().getTime() / 1000) == (two .getResponseDate().getTime() / 1000))) { - return false; - } + return false; + } if (!one.getProtocolVersion().equals(two.getProtocolVersion())) { - return false; - } + return false; + } byte[] onesByteArray = resourceToBytes(one.getResource()); byte[] twosByteArray = resourceToBytes(two.getResource()); if (!Arrays.equals(onesByteArray,twosByteArray)) { - return false; - } + return false; + } Header[] oneHeaders = one.getAllHeaders(); Header[] twoHeaders = two.getAllHeaders(); if (!(oneHeaders.length == twoHeaders.length)) { - return false; - } + return false; + } for (int i = 0; i < oneHeaders.length; i++) { if (!oneHeaders[i].getName().equals(twoHeaders[i].getName())) { - return false; - } + return false; + } if (!oneHeaders[i].getValue().equals(twoHeaders[i].getValue())) { - return false; - } + return false; + } } return true; diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java index d3b63a4de..448ea0250 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestProtocolRequirements.java @@ -1652,11 +1652,11 @@ public class TestProtocolRequirements extends AbstractProtocolTest { boolean found2 = false; while ((b = i.read()) != -1) { if (b == 1) { - found1 = true; - } + found1 = true; + } if (b == 2) { - found2 = true; - } + found2 = true; + } } i.close(); Assert.assertFalse(found1 && found2); // mixture of content @@ -1746,11 +1746,11 @@ public class TestProtocolRequirements extends AbstractProtocolTest { boolean found2 = false; while ((b = i.read()) != -1) { if (b == 1) { - found1 = true; - } + found1 = true; + } if (b == 2) { - found2 = true; - } + found2 = true; + } } i.close(); Assert.assertFalse(found1 && found2); // mixture of content @@ -2614,8 +2614,8 @@ public class TestProtocolRequirements extends AbstractProtocolTest { boolean foundWarning = false; for (Header h : result.getHeaders("Warning")) { if (h.getValue().split(" ")[0].equals("111")) { - foundWarning = true; - } + foundWarning = true; + } } Assert.assertTrue(foundWarning); } else { @@ -2692,15 +2692,15 @@ public class TestProtocolRequirements extends AbstractProtocolTest { for (Header h : result1.getHeaders("Warning")) { for (HeaderElement elt : h.getElements()) { if (elt.getName().startsWith("1")) { - found1xxWarning = true; - } + found1xxWarning = true; + } } } for (Header h : result2.getHeaders("Warning")) { for (HeaderElement elt : h.getElements()) { if (elt.getName().startsWith("1")) { - found1xxWarning = true; - } + found1xxWarning = true; + } } } Assert.assertFalse(found1xxWarning); @@ -2765,8 +2765,8 @@ public class TestProtocolRequirements extends AbstractProtocolTest { for (HeaderElement elt : h.getElements()) { String[] parts = elt.getName().split(" "); if ("214".equals(parts[0])) { - found214Warning = true; - } + found214Warning = true; + } } } Assert.assertTrue(found214Warning); @@ -2776,8 +2776,8 @@ public class TestProtocolRequirements extends AbstractProtocolTest { for (HeaderElement elt : h.getElements()) { String[] parts = elt.getName().split(" "); if ("214".equals(parts[0])) { - found214Warning = true; - } + found214Warning = true; + } } } Assert.assertTrue(found214Warning); @@ -3170,15 +3170,15 @@ public class TestProtocolRequirements extends AbstractProtocolTest { for (Header h : validation.getHeaders("If-Match")) { for (HeaderElement elt : h.getElements()) { if ("W/\"etag\"".equals(elt.getName())) { - foundETag = true; - } + foundETag = true; + } } } for (Header h : validation.getHeaders("If-None-Match")) { for (HeaderElement elt : h.getElements()) { if ("W/\"etag\"".equals(elt.getName())) { - foundETag = true; - } + foundETag = true; + } } } Assert.assertTrue(foundETag); @@ -6062,16 +6062,16 @@ public class TestProtocolRequirements extends AbstractProtocolTest { final String nestedSuffix = "\\)([^\\p{Cntrl}()]|\\\\\\p{ASCII})*\\)$"; if (Pattern.matches(leafComment,s)) { - return true; - } + return true; + } Matcher pref = Pattern.compile(nestedPrefix).matcher(s); Matcher suff = Pattern.compile(nestedSuffix).matcher(s); if (!pref.find()) { - return false; - } + return false; + } if (!suff.find()) { - return false; - } + return false; + } return isValidComment(s.substring(pref.end() - 1, suff.start() + 1)); } diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java index 2edf93b79..2a31a6bbf 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/memcached/TestMemcachedHttpCacheStorage.java @@ -487,8 +487,8 @@ public class TestMemcachedHttpCacheStorage extends TestCase { HttpCacheUpdateCallback callback = new HttpCacheUpdateCallback() { public HttpCacheEntry update(final HttpCacheEntry old) { if (old == existingValue) { - return updatedValue; - } + return updatedValue; + } assertSame(existingValue2, old); return updatedValue2; } diff --git a/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java b/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java index 6210c6de6..f2485defa 100644 --- a/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java +++ b/httpclient/src/main/java/org/apache/http/auth/BasicUserPrincipal.java @@ -65,8 +65,8 @@ public final class BasicUserPrincipal implements Principal, Serializable { @Override public boolean equals(final Object o) { if (this == o) { - return true; - } + return true; + } if (o instanceof BasicUserPrincipal) { BasicUserPrincipal that = (BasicUserPrincipal) o; if (LangUtils.equals(this.username, that.username)) { diff --git a/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java b/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java index 6ad600a3d..0d582f8e5 100644 --- a/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java +++ b/httpclient/src/main/java/org/apache/http/auth/NTCredentials.java @@ -151,8 +151,8 @@ public class NTCredentials implements Credentials, Serializable { @Override public boolean equals(final Object o) { if (this == o) { - return true; - } + return true; + } if (o instanceof NTCredentials) { NTCredentials that = (NTCredentials) o; if (LangUtils.equals(this.principal, that.principal) diff --git a/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java b/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java index 3253b933e..1bb2b7688 100644 --- a/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java +++ b/httpclient/src/main/java/org/apache/http/auth/NTUserPrincipal.java @@ -93,8 +93,8 @@ public class NTUserPrincipal implements Principal, Serializable { @Override public boolean equals(final Object o) { if (this == o) { - return true; - } + return true; + } if (o instanceof NTUserPrincipal) { NTUserPrincipal that = (NTUserPrincipal) o; if (LangUtils.equals(this.username, that.username) diff --git a/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java b/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java index 12238c81e..3e5eafe7f 100644 --- a/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java +++ b/httpclient/src/main/java/org/apache/http/auth/UsernamePasswordCredentials.java @@ -100,8 +100,8 @@ public class UsernamePasswordCredentials implements Credentials, Serializable { @Override public boolean equals(final Object o) { if (this == o) { - return true; - } + return true; + } if (o instanceof UsernamePasswordCredentials) { UsernamePasswordCredentials that = (UsernamePasswordCredentials) o; if (LangUtils.equals(this.principal, that.principal)) { diff --git a/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java b/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java index 39fb1aad0..d3d12e5e4 100644 --- a/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java +++ b/httpclient/src/main/java/org/apache/http/client/utils/Rfc3492Idn.java @@ -49,10 +49,10 @@ public class Rfc3492Idn implements Idn { private int adapt(int delta, final int numpoints, final boolean firsttime) { if (firsttime) { - delta = delta / damp; - } else { - delta = delta / 2; - } + delta = delta / damp; + } else { + delta = delta / 2; + } delta = delta + (delta / numpoints); int k = 0; while (delta > ((base - tmin) * tmax) / 2) { @@ -64,14 +64,14 @@ public class Rfc3492Idn implements Idn { private int digit(final char c) { if ((c >= 'A') && (c <= 'Z')) { - return (c - 'A'); - } + return (c - 'A'); + } if ((c >= 'a') && (c <= 'z')) { - return (c - 'a'); - } + return (c - 'a'); + } if ((c >= '0') && (c <= '9')) { - return (c - '0') + 26; - } + return (c - '0') + 26; + } throw new IllegalArgumentException("illegal digit: "+ c); } @@ -81,11 +81,11 @@ public class Rfc3492Idn implements Idn { while (tok.hasMoreTokens()) { String t = tok.nextToken(); if (unicode.length() > 0) { - unicode.append('.'); - } + unicode.append('.'); + } if (t.startsWith(ACE_PREFIX)) { - t = decode(t.substring(4)); - } + t = decode(t.substring(4)); + } unicode.append(t); } return unicode.toString(); @@ -107,8 +107,8 @@ public class Rfc3492Idn implements Idn { int w = 1; for (int k = base;; k += base) { if (input.length() == 0) { - break; - } + break; + } char c = input.charAt(0); input = input.substring(1); int digit = digit(c); @@ -122,8 +122,8 @@ public class Rfc3492Idn implements Idn { t = k - bias; } if (digit < t) { - break; - } + break; + } w = w * (base - t); // FIXME fail on overflow } bias = adapt(i - oldi, output.length() + 1, (oldi == 0)); diff --git a/httpclient/src/main/java/org/apache/http/conn/BasicManagedEntity.java b/httpclient/src/main/java/org/apache/http/conn/BasicManagedEntity.java index a65d84fcd..c1eb53329 100644 --- a/httpclient/src/main/java/org/apache/http/conn/BasicManagedEntity.java +++ b/httpclient/src/main/java/org/apache/http/conn/BasicManagedEntity.java @@ -89,8 +89,8 @@ public class BasicManagedEntity extends HttpEntityWrapper private void ensureConsumed() throws IOException { if (managedConn == null) { - return; - } + return; + } try { if (attemptReuse) { diff --git a/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java b/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java index 00b1bd7fe..7d9959017 100644 --- a/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java +++ b/httpclient/src/main/java/org/apache/http/conn/EofSensorInputStream.java @@ -196,11 +196,11 @@ public class EofSensorInputStream extends InputStream implements ConnectionRelea try { boolean scws = true; // should close wrapped stream? if (eofWatcher != null) { - scws = eofWatcher.eofDetected(wrappedStream); - } + scws = eofWatcher.eofDetected(wrappedStream); + } if (scws) { - wrappedStream.close(); - } + wrappedStream.close(); + } } finally { wrappedStream = null; } @@ -224,11 +224,11 @@ public class EofSensorInputStream extends InputStream implements ConnectionRelea try { boolean scws = true; // should close wrapped stream? if (eofWatcher != null) { - scws = eofWatcher.streamClosed(wrappedStream); - } + scws = eofWatcher.streamClosed(wrappedStream); + } if (scws) { - wrappedStream.close(); - } + wrappedStream.close(); + } } finally { wrappedStream = null; } @@ -254,11 +254,11 @@ public class EofSensorInputStream extends InputStream implements ConnectionRelea try { boolean scws = true; // should close wrapped stream? if (eofWatcher != null) { - scws = eofWatcher.streamAbort(wrappedStream); - } + scws = eofWatcher.streamAbort(wrappedStream); + } if (scws) { - wrappedStream.close(); - } + wrappedStream.close(); + } } finally { wrappedStream = null; } diff --git a/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java index 4b6e49ad0..18d4e4b75 100644 --- a/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java @@ -111,16 +111,16 @@ public final class MultihomePlainSocketFactory implements SocketFactory { Args.notNull(params, "HTTP parameters"); if (sock == null) { - sock = createSocket(); - } + sock = createSocket(); + } if ((localAddress != null) || (localPort > 0)) { // we need to bind explicitly if (localPort < 0) - { - localPort = 0; // indicates "any" - } + { + localPort = 0; // indicates "any" + } InetSocketAddress isa = new InetSocketAddress(localAddress, localPort); diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java b/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java index 75e570929..5bb8a5318 100644 --- a/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java +++ b/httpclient/src/main/java/org/apache/http/conn/routing/BasicRouteDirector.java @@ -56,12 +56,12 @@ public class BasicRouteDirector implements HttpRouteDirector { int step = UNREACHABLE; if ((fact == null) || (fact.getHopCount() < 1)) { - step = firstStep(plan); - } else if (plan.getHopCount() > 1) { - step = proxiedStep(plan, fact); - } else { - step = directStep(plan, fact); - } + step = firstStep(plan); + } else if (plan.getHopCount() > 1) { + step = proxiedStep(plan, fact); + } else { + step = directStep(plan, fact); + } return step; @@ -94,29 +94,29 @@ public class BasicRouteDirector implements HttpRouteDirector { protected int directStep(final RouteInfo plan, final RouteInfo fact) { if (fact.getHopCount() > 1) { - return UNREACHABLE; - } + return UNREACHABLE; + } if (!plan.getTargetHost().equals(fact.getTargetHost())) - { - return UNREACHABLE; + { + return UNREACHABLE; // If the security is too low, we could now suggest to layer // a secure protocol on the direct connection. Layering on direct // connections has not been supported in HttpClient 3.x, we don't // consider it here until there is a real-life use case for it. - } + } // Should we tolerate if security is better than planned? // (plan.isSecure() && !fact.isSecure()) if (plan.isSecure() != fact.isSecure()) { - return UNREACHABLE; - } + return UNREACHABLE; + } // Local address has to match only if the plan specifies one. if ((plan.getLocalAddress() != null) && !plan.getLocalAddress().equals(fact.getLocalAddress()) ) { - return UNREACHABLE; - } + return UNREACHABLE; + } return COMPLETE; } @@ -134,47 +134,47 @@ public class BasicRouteDirector implements HttpRouteDirector { protected int proxiedStep(final RouteInfo plan, final RouteInfo fact) { if (fact.getHopCount() <= 1) { - return UNREACHABLE; - } + return UNREACHABLE; + } if (!plan.getTargetHost().equals(fact.getTargetHost())) { - return UNREACHABLE; - } + return UNREACHABLE; + } final int phc = plan.getHopCount(); final int fhc = fact.getHopCount(); if (phc < fhc) { - return UNREACHABLE; - } + return UNREACHABLE; + } for (int i=0; i fhc) - { - return TUNNEL_PROXY; // need to extend the proxy chain - } + { + return TUNNEL_PROXY; // need to extend the proxy chain + } // proxy chain and target are the same, check tunnelling and layering if ((fact.isTunnelled() && !plan.isTunnelled()) || (fact.isLayered() && !plan.isLayered())) { - return UNREACHABLE; - } + return UNREACHABLE; + } if (plan.isTunnelled() && !fact.isTunnelled()) { - return TUNNEL_TARGET; - } + return TUNNEL_TARGET; + } if (plan.isLayered() && !fact.isLayered()) { - return LAYER_PROTOCOL; - } + return LAYER_PROTOCOL; + } // tunnel and layering are the same, remains to check the security // Should we tolerate if security is better than planned? // (plan.isSecure() && !fact.isSecure()) if (plan.isSecure() != fact.isSecure()) { - return UNREACHABLE; - } + return UNREACHABLE; + } return COMPLETE; } diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java index 585a937ba..d3d798f85 100644 --- a/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java +++ b/httpclient/src/main/java/org/apache/http/conn/routing/HttpRoute.java @@ -102,11 +102,11 @@ public final class HttpRoute implements RouteInfo, Cloneable { } // tunnelled is already checked above, that is in line with the default if (tunnelled == null) { - tunnelled = TunnelType.PLAIN; - } + tunnelled = TunnelType.PLAIN; + } if (layered == null) { - layered = LayerType.PLAIN; - } + layered = LayerType.PLAIN; + } this.targetHost = target; this.localAddress = local; @@ -215,8 +215,8 @@ public final class HttpRoute implements RouteInfo, Cloneable { */ private static HttpHost[] toChain(final HttpHost proxy) { if (proxy == null) { - return EMPTY_HTTP_HOST_ARRAY; - } + return EMPTY_HTTP_HOST_ARRAY; + } return new HttpHost[]{ proxy }; } @@ -232,8 +232,8 @@ public final class HttpRoute implements RouteInfo, Cloneable { */ private static HttpHost[] toChain(final HttpHost[] proxies) { if ((proxies == null) || (proxies.length < 1)) { - return EMPTY_HTTP_HOST_ARRAY; - } + return EMPTY_HTTP_HOST_ARRAY; + } // copy the proxy chain, the traditional way HttpHost[] result = new HttpHost[proxies.length]; System.arraycopy(proxies, 0, result, 0, proxies.length); @@ -267,10 +267,10 @@ public final class HttpRoute implements RouteInfo, Cloneable { HttpHost result = null; if (hop < hopcount-1) { - result = this.proxyChain[hop]; - } else { - result = this.targetHost; - } + result = this.proxyChain[hop]; + } else { + result = this.targetHost; + } return result; } @@ -317,8 +317,8 @@ public final class HttpRoute implements RouteInfo, Cloneable { @Override public final boolean equals(final Object obj) { if (this == obj) { - return true; - } + return true; + } if (obj instanceof HttpRoute) { HttpRoute that = (HttpRoute) obj; return @@ -369,14 +369,14 @@ public final class HttpRoute implements RouteInfo, Cloneable { } cab.append('{'); if (this.tunnelled == TunnelType.TUNNELLED) { - cab.append('t'); - } + cab.append('t'); + } if (this.layered == LayerType.LAYERED) { - cab.append('l'); - } + cab.append('l'); + } if (this.secure) { - cab.append('s'); - } + cab.append('s'); + } cab.append("}->"); for (HttpHost aProxyChain : this.proxyChain) { cab.append(aProxyChain); diff --git a/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java b/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java index 53c9d9a5e..c12282d5f 100644 --- a/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java +++ b/httpclient/src/main/java/org/apache/http/conn/routing/RouteTracker.java @@ -197,10 +197,10 @@ public final class RouteTracker implements RouteInfo, Cloneable { int hops = 0; if (this.connected) { if (proxyChain == null) { - hops = 1; - } else { - hops = proxyChain.length + 1; - } + hops = 1; + } else { + hops = proxyChain.length + 1; + } } return hops; } @@ -211,10 +211,10 @@ public final class RouteTracker implements RouteInfo, Cloneable { Args.check(hop < hopcount, "Hop index exceeds tracked route length"); HttpHost result = null; if (hop < hopcount-1) { - result = this.proxyChain[hop]; - } else { - result = this.targetHost; - } + result = this.proxyChain[hop]; + } else { + result = this.targetHost; + } return result; } @@ -273,11 +273,11 @@ public final class RouteTracker implements RouteInfo, Cloneable { @Override public final boolean equals(final Object o) { if (o == this) { - return true; - } + return true; + } if (!(o instanceof RouteTracker)) { - return false; - } + return false; + } RouteTracker that = (RouteTracker) o; return @@ -332,17 +332,17 @@ public final class RouteTracker implements RouteInfo, Cloneable { } cab.append('{'); if (this.connected) { - cab.append('c'); - } + cab.append('c'); + } if (this.tunnelled == TunnelType.TUNNELLED) { - cab.append('t'); - } + cab.append('t'); + } if (this.layered == LayerType.LAYERED) { - cab.append('l'); - } + cab.append('l'); + } if (this.secure) { - cab.append('s'); - } + cab.append('s'); + } cab.append("}->"); if (this.proxyChain != null) { for (HttpHost element : this.proxyChain) { diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java b/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java index d3b306df6..c040aee52 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/Scheme.java @@ -238,8 +238,8 @@ public final class Scheme { @Override public final boolean equals(final Object obj) { if (this == obj) { - return true; - } + return true; + } if (obj instanceof Scheme) { Scheme that = (Scheme) obj; return this.name.equals(that.name) diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java index 191eef7a5..4b631f5fc 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java @@ -80,11 +80,11 @@ class SchemeSocketFactoryAdaptor implements SchemeSocketFactory { @Override public boolean equals(final Object obj) { if (obj == null) { - return false; - } + return false; + } if (this == obj) { - return true; - } + return true; + } if (obj instanceof SchemeSocketFactoryAdaptor) { return this.factory.equals(((SchemeSocketFactoryAdaptor)obj).factory); } else { diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java b/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java index fbfca7ce1..1c2f48e07 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/SocketFactoryAdaptor.java @@ -84,11 +84,11 @@ class SocketFactoryAdaptor implements SocketFactory { @Override public boolean equals(final Object obj) { if (obj == null) { - return false; - } + return false; + } if (this == obj) { - return true; - } + return true; + } if (obj instanceof SocketFactoryAdaptor) { return this.factory.equals(((SocketFactoryAdaptor)obj).factory); } else { diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java index efaa1a928..edf226d2a 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/GGSSchemeBase.java @@ -162,16 +162,16 @@ public abstract class GGSSchemeBase extends AuthSchemeBase { state = State.FAILED; if (gsse.getMajor() == GSSException.DEFECTIVE_CREDENTIAL || gsse.getMajor() == GSSException.CREDENTIALS_EXPIRED) { - throw new InvalidCredentialsException(gsse.getMessage(), gsse); - } + throw new InvalidCredentialsException(gsse.getMessage(), gsse); + } if (gsse.getMajor() == GSSException.NO_CRED ) { - throw new InvalidCredentialsException(gsse.getMessage(), gsse); - } + throw new InvalidCredentialsException(gsse.getMessage(), gsse); + } if (gsse.getMajor() == GSSException.DEFECTIVE_TOKEN || gsse.getMajor() == GSSException.DUPLICATE_TOKEN || gsse.getMajor() == GSSException.OLD_TOKEN) { - throw new AuthenticationException(gsse.getMessage(), gsse); - } + throw new AuthenticationException(gsse.getMessage(), gsse); + } // other error throw new AuthenticationException(gsse.getMessage()); } diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java index f25ab516f..5f7cda21d 100644 --- a/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java +++ b/httpclient/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java @@ -186,8 +186,8 @@ final class NTLMEngineImpl implements NTLMEngine { private static String stripDotSuffix(final String value) { int index = value.indexOf("."); if (index != -1) { - return value.substring(0, index); - } + return value.substring(0, index); + } return value; } @@ -203,16 +203,16 @@ final class NTLMEngineImpl implements NTLMEngine { private static int readULong(final byte[] src, final int index) throws NTLMEngineException { if (src.length < index + 4) { - throw new NTLMEngineException("NTLM authentication - buffer too small for DWORD"); - } + throw new NTLMEngineException("NTLM authentication - buffer too small for DWORD"); + } return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8) | ((src[index + 2] & 0xff) << 16) | ((src[index + 3] & 0xff) << 24); } private static int readUShort(final byte[] src, final int index) throws NTLMEngineException { if (src.length < index + 2) { - throw new NTLMEngineException("NTLM authentication - buffer too small for WORD"); - } + throw new NTLMEngineException("NTLM authentication - buffer too small for WORD"); + } return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8); } @@ -220,9 +220,9 @@ final class NTLMEngineImpl implements NTLMEngine { int length = readUShort(src, index); int offset = readULong(src, index + 4); if (src.length < offset + length) { - throw new NTLMEngineException( + throw new NTLMEngineException( "NTLM authentication - buffer too small for data item"); - } + } byte[] buffer = new byte[length]; System.arraycopy(src, offset, buffer, 0, length); return buffer; @@ -304,8 +304,8 @@ final class NTLMEngineImpl implements NTLMEngine { public byte[] getClientChallenge() throws NTLMEngineException { if (clientChallenge == null) { - clientChallenge = makeRandomChallenge(); - } + clientChallenge = makeRandomChallenge(); + } return clientChallenge; } @@ -313,8 +313,8 @@ final class NTLMEngineImpl implements NTLMEngine { public byte[] getSecondaryKey() throws NTLMEngineException { if (secondaryKey == null) { - secondaryKey = makeSecondaryKey(); - } + secondaryKey = makeSecondaryKey(); + } return secondaryKey; } @@ -322,8 +322,8 @@ final class NTLMEngineImpl implements NTLMEngine { public byte[] getLMHash() throws NTLMEngineException { if (lmHash == null) { - lmHash = lmHash(password); - } + lmHash = lmHash(password); + } return lmHash; } @@ -331,8 +331,8 @@ final class NTLMEngineImpl implements NTLMEngine { public byte[] getLMResponse() throws NTLMEngineException { if (lmResponse == null) { - lmResponse = lmResponse(getLMHash(),challenge); - } + lmResponse = lmResponse(getLMHash(),challenge); + } return lmResponse; } @@ -340,8 +340,8 @@ final class NTLMEngineImpl implements NTLMEngine { public byte[] getNTLMHash() throws NTLMEngineException { if (ntlmHash == null) { - ntlmHash = ntlmHash(password); - } + ntlmHash = ntlmHash(password); + } return ntlmHash; } @@ -349,8 +349,8 @@ final class NTLMEngineImpl implements NTLMEngine { public byte[] getNTLMResponse() throws NTLMEngineException { if (ntlmResponse == null) { - ntlmResponse = lmResponse(getNTLMHash(),challenge); - } + ntlmResponse = lmResponse(getNTLMHash(),challenge); + } return ntlmResponse; } @@ -358,8 +358,8 @@ final class NTLMEngineImpl implements NTLMEngine { public byte[] getNTLMv2Hash() throws NTLMEngineException { if (ntlmv2Hash == null) { - ntlmv2Hash = ntlmv2Hash(target, user, password); - } + ntlmv2Hash = ntlmv2Hash(target, user, password); + } return ntlmv2Hash; } @@ -383,8 +383,8 @@ final class NTLMEngineImpl implements NTLMEngine { public byte[] getNTLMv2Blob() throws NTLMEngineException { if (ntlmv2Blob == null) { - ntlmv2Blob = createBlob(getClientChallenge(), targetInformation, getTimestamp()); - } + ntlmv2Blob = createBlob(getClientChallenge(), targetInformation, getTimestamp()); + } return ntlmv2Blob; } @@ -392,8 +392,8 @@ final class NTLMEngineImpl implements NTLMEngine { public byte[] getNTLMv2Response() throws NTLMEngineException { if (ntlmv2Response == null) { - ntlmv2Response = lmv2Response(getNTLMv2Hash(),challenge,getNTLMv2Blob()); - } + ntlmv2Response = lmv2Response(getNTLMv2Hash(),challenge,getNTLMv2Blob()); + } return ntlmv2Response; } @@ -401,8 +401,8 @@ final class NTLMEngineImpl implements NTLMEngine { public byte[] getLMv2Response() throws NTLMEngineException { if (lmv2Response == null) { - lmv2Response = lmv2Response(getNTLMv2Hash(),challenge,getClientChallenge()); - } + lmv2Response = lmv2Response(getNTLMv2Hash(),challenge,getClientChallenge()); + } return lmv2Response; } @@ -410,8 +410,8 @@ final class NTLMEngineImpl implements NTLMEngine { public byte[] getNTLM2SessionResponse() throws NTLMEngineException { if (ntlm2SessionResponse == null) { - ntlm2SessionResponse = ntlm2SessionResponse(getNTLMHash(),challenge,getClientChallenge()); - } + ntlm2SessionResponse = ntlm2SessionResponse(getNTLMHash(),challenge,getClientChallenge()); + } return ntlm2SessionResponse; } @@ -573,8 +573,8 @@ final class NTLMEngineImpl implements NTLMEngine { return lmResponse(ntlmHash, sessionHash); } catch (Exception e) { if (e instanceof NTLMEngineException) { - throw (NTLMEngineException) e; - } + throw (NTLMEngineException) e; + } throw new NTLMEngineException(e.getMessage(), e); } } @@ -819,23 +819,23 @@ final class NTLMEngineImpl implements NTLMEngine { DEFAULT_CHARSET)); // Look for NTLM message if (messageContents.length < SIGNATURE.length) { - throw new NTLMEngineException("NTLM message decoding error - packet too short"); - } + throw new NTLMEngineException("NTLM message decoding error - packet too short"); + } int i = 0; while (i < SIGNATURE.length) { if (messageContents[i] != SIGNATURE[i]) { - throw new NTLMEngineException( + throw new NTLMEngineException( "NTLM message expected - instead got unrecognized bytes"); - } + } i++; } // Check to be sure there's a type 2 message indicator next int type = readULong(SIGNATURE.length); if (type != expectedType) { - throw new NTLMEngineException("NTLM type " + Integer.toString(expectedType) + throw new NTLMEngineException("NTLM type " + Integer.toString(expectedType) + " message expected - instead got type " + Integer.toString(type)); - } + } currentOutputPosition = messageContents.length; } @@ -856,16 +856,16 @@ final class NTLMEngineImpl implements NTLMEngine { /** Read a byte from a position within the message buffer */ protected byte readByte(final int position) throws NTLMEngineException { if (messageContents.length < position + 1) { - throw new NTLMEngineException("NTLM: Message too short"); - } + throw new NTLMEngineException("NTLM: Message too short"); + } return messageContents[position]; } /** Read a bunch of bytes from a position in the message buffer */ protected void readBytes(final byte[] buffer, final int position) throws NTLMEngineException { if (messageContents.length < position + buffer.length) { - throw new NTLMEngineException("NTLM: Message too short"); - } + throw new NTLMEngineException("NTLM: Message too short"); + } System.arraycopy(messageContents, position, buffer, 0, buffer.length); } @@ -1084,10 +1084,10 @@ final class NTLMEngineImpl implements NTLMEngine { flags = readULong(20); if ((flags & FLAG_REQUEST_UNICODE_ENCODING) == 0) { - throw new NTLMEngineException( + throw new NTLMEngineException( "NTLM type 2 message has flags that make no sense: " + Integer.toString(flags)); - } + } // Do the target! target = null; @@ -1179,10 +1179,10 @@ final class NTLMEngineImpl implements NTLMEngine { ntResp = gen.getNTLMv2Response(); lmResp = gen.getLMv2Response(); if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) { - userSessionKey = gen.getLanManagerSessionKey(); - } else { - userSessionKey = gen.getNTLMv2UserSessionKey(); - } + userSessionKey = gen.getLanManagerSessionKey(); + } else { + userSessionKey = gen.getNTLMv2UserSessionKey(); + } } else { // NTLMv1 if ((type2Flags & FLAG_REQUEST_NTLM2_SESSION) != 0) { @@ -1190,23 +1190,23 @@ final class NTLMEngineImpl implements NTLMEngine { ntResp = gen.getNTLM2SessionResponse(); lmResp = gen.getLM2SessionResponse(); if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) { - userSessionKey = gen.getLanManagerSessionKey(); - } - else { - userSessionKey = gen.getNTLM2SessionResponseUserSessionKey(); + userSessionKey = gen.getLanManagerSessionKey(); + } + else { + userSessionKey = gen.getNTLM2SessionResponseUserSessionKey(); // All the other flags we send (signing, sealing, key // exchange) are supported, but they don't do anything // at all in an // NTLM2 context! So we're done at this point. - } + } } else { ntResp = gen.getNTLMResponse(); lmResp = gen.getLMResponse(); if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) { - userSessionKey = gen.getLanManagerSessionKey(); - } else { - userSessionKey = gen.getNTLMUserSessionKey(); - } + userSessionKey = gen.getLanManagerSessionKey(); + } else { + userSessionKey = gen.getNTLMUserSessionKey(); + } } } } catch (NTLMEngineException e) { @@ -1215,17 +1215,17 @@ final class NTLMEngineImpl implements NTLMEngine { ntResp = new byte[0]; lmResp = gen.getLMResponse(); if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) { - userSessionKey = gen.getLanManagerSessionKey(); - } else { - userSessionKey = gen.getLMUserSessionKey(); - } + userSessionKey = gen.getLanManagerSessionKey(); + } else { + userSessionKey = gen.getLMUserSessionKey(); + } } if ((type2Flags & FLAG_REQUEST_EXPLICIT_KEY_EXCH) != 0) { - sessionKey = RC4(gen.getSecondaryKey(), userSessionKey); - } else { - sessionKey = null; - } + sessionKey = RC4(gen.getSecondaryKey(), userSessionKey); + } else { + sessionKey = null; + } try { domainBytes = domain.toUpperCase(Locale.US).getBytes("UnicodeLittleUnmarked"); @@ -1247,10 +1247,10 @@ final class NTLMEngineImpl implements NTLMEngine { int userLen = userBytes.length; int sessionKeyLen; if (sessionKey != null) { - sessionKeyLen = sessionKey.length; - } else { - sessionKeyLen = 0; - } + sessionKeyLen = sessionKey.length; + } else { + sessionKeyLen = 0; + } // Calculate the layout within the packet int lmRespOffset = 72; // allocate space for the version @@ -1349,8 +1349,8 @@ final class NTLMEngineImpl implements NTLMEngine { addBytes(userBytes); addBytes(hostBytes); if (sessionKey != null) { - addBytes(sessionKey); - } + addBytes(sessionKey); + } return super.getResponse(); } diff --git a/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java b/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java index a3457b5cc..6bcc3a242 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java @@ -88,8 +88,8 @@ public class AIMDBackoffManager implements BackoffManager { Long lastUpdate = getLastUpdate(lastRouteBackoffs, route); long now = clock.getCurrentTime(); if (now - lastUpdate.longValue() < coolDown) { - return; - } + return; + } connPerRoute.setMaxPerRoute(route, getBackedOffPoolSize(curr)); lastRouteBackoffs.put(route, Long.valueOf(now)); } @@ -97,8 +97,8 @@ public class AIMDBackoffManager implements BackoffManager { private int getBackedOffPoolSize(final int curr) { if (curr <= 1) { - return 1; - } + return 1; + } return (int)(Math.floor(backoffFactor * curr)); } @@ -110,8 +110,8 @@ public class AIMDBackoffManager implements BackoffManager { Long lastBackoff = getLastUpdate(lastRouteBackoffs, route); long now = clock.getCurrentTime(); if (now - lastProbe.longValue() < coolDown || now - lastBackoff.longValue() < coolDown) { - return; - } + return; + } connPerRoute.setMaxPerRoute(route, max); lastRouteProbes.put(route, Long.valueOf(now)); } @@ -120,8 +120,8 @@ public class AIMDBackoffManager implements BackoffManager { private Long getLastUpdate(final Map updates, final HttpRoute route) { Long lastUpdate = updates.get(route); if (lastUpdate == null) { - lastUpdate = Long.valueOf(0L); - } + lastUpdate = Long.valueOf(0L); + } return lastUpdate; } diff --git a/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java index dd1686e73..4464c1a79 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java @@ -841,11 +841,11 @@ public abstract class AbstractHttpClient extends CloseableHttpClient { backoffManager.backOff(route); } if (e instanceof HttpException) { - throw (HttpException)e; - } + throw (HttpException)e; + } if (e instanceof IOException) { - throw (IOException)e; - } + throw (IOException)e; + } throw new UndeclaredThrowableException(e); } if (connectionBackoffStrategy.shouldBackoff(out)) { diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java b/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java index cfd1e269f..05f99a8b9 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DecompressingHttpClient.java @@ -148,8 +148,8 @@ public class DecompressingHttpClient implements HttpClient { HttpContext context) throws IOException, ClientProtocolException { try { if (context == null) { - context = new BasicHttpContext(); - } + context = new BasicHttpContext(); + } HttpRequest wrapped; if (request instanceof HttpEntityEnclosingRequest) { wrapped = new EntityEnclosingRequestWrapper((HttpEntityEnclosingRequest) request); @@ -208,8 +208,8 @@ public class DecompressingHttpClient implements HttpClient { } finally { HttpEntity entity = response.getEntity(); if (entity != null) { - EntityUtils.consume(entity); - } + EntityUtils.consume(entity); + } } } diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java index 3d803ec21..d9cc6f2c8 100644 --- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java +++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultRequestDirector.java @@ -563,8 +563,8 @@ public class DefaultRequestDirector implements RequestDirector { !response.getEntity().isStreaming()) { // connection not needed and (assumed to be) in re-usable state if (reuse) { - managedConn.markReusable(); - } + managedConn.markReusable(); + } releaseConnection(); } else { // install an auto-release entity diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java b/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java index 2599aadbc..6715d0242 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/AbstractClientConnAdapter.java @@ -159,20 +159,20 @@ public abstract class AbstractClientConnAdapter implements ManagedClientConnecti public boolean isOpen() { OperatedClientConnection conn = getWrappedConnection(); if (conn == null) { - return false; - } + return false; + } return conn.isOpen(); } public boolean isStale() { if (isReleased()) { - return true; - } + return true; + } OperatedClientConnection conn = getWrappedConnection(); if (conn == null) { - return true; - } + return true; + } return conn.isStale(); } @@ -277,8 +277,8 @@ public abstract class AbstractClientConnAdapter implements ManagedClientConnecti OperatedClientConnection conn = getWrappedConnection(); assertValid(conn); if (!isOpen()) { - return null; - } + return null; + } return conn.getSocket(); } @@ -286,8 +286,8 @@ public abstract class AbstractClientConnAdapter implements ManagedClientConnecti OperatedClientConnection conn = getWrappedConnection(); assertValid(conn); if (!isOpen()) { - return null; - } + return null; + } SSLSession result = null; Socket sock = conn.getSocket(); diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java b/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java index 89470d237..258948b51 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/AbstractPooledConnAdapter.java @@ -151,8 +151,8 @@ public abstract class AbstractPooledConnAdapter extends AbstractClientConnAdapte public void close() throws IOException { AbstractPoolEntry entry = getPoolEntry(); if (entry != null) { - entry.shutdownEntry(); - } + entry.shutdownEntry(); + } OperatedClientConnection conn = getWrappedConnection(); if (conn != null) { @@ -163,8 +163,8 @@ public abstract class AbstractPooledConnAdapter extends AbstractClientConnAdapte public void shutdown() throws IOException { AbstractPoolEntry entry = getPoolEntry(); if (entry != null) { - entry.shutdownEntry(); - } + entry.shutdownEntry(); + } OperatedClientConnection conn = getWrappedConnection(); if (conn != null) { diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java index c29e06709..1af119de1 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnection.java @@ -157,8 +157,8 @@ public class DefaultClientConnection extends SocketHttpClientConnection } Socket sock = this.socket; // copy volatile attribute if (sock != null) { - sock.close(); - } + sock.close(); + } } catch (IOException ex) { log.debug("I/O error shutting down connection", ex); } diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java index ff00667be..f1ebc6f22 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultHttpRoutePlanner.java @@ -89,8 +89,8 @@ public class DefaultHttpRoutePlanner implements HttpRoutePlanner { HttpRoute route = ConnRouteParams.getForcedRoute(request.getParams()); if (route != null) { - return route; - } + return route; + } // If we get here, there is no forced route. // So we need a target to compute a route. diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java index d74a8febb..4627a2875 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/ProxySelectorRoutePlanner.java @@ -125,8 +125,8 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner { HttpRoute route = ConnRouteParams.getForcedRoute(request.getParams()); if (route != null) { - return route; - } + return route; + } // If we get here, there is no forced route. // So we need a target to compute a route. @@ -171,11 +171,11 @@ public class ProxySelectorRoutePlanner implements HttpRoutePlanner { // the proxy selector can be 'unset', so we better deal with null here ProxySelector psel = this.proxySelector; if (psel == null) { - psel = ProxySelector.getDefault(); - } + psel = ProxySelector.getDefault(); + } if (psel == null) { - return null; - } + return null; + } URI targetURI = null; try { diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java b/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java index 8742315c9..9067b1006 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/SingleClientConnManager.java @@ -244,8 +244,8 @@ public class SingleClientConnManager implements ClientConnectionManager { } if (recreate) { - uniquePoolEntry = new PoolEntry(); - } + uniquePoolEntry = new PoolEntry(); + } managedConn = new ConnAdapter(uniquePoolEntry, route); @@ -267,9 +267,9 @@ public class SingleClientConnManager implements ClientConnectionManager { ConnAdapter sca = (ConnAdapter) conn; synchronized (sca) { if (sca.poolEntry == null) - { - return; // already released - } + { + return; // already released + } ClientConnectionManager manager = sca.getManager(); Asserts.check(manager == this, "Connection not obtained from this manager"); try { @@ -289,19 +289,19 @@ public class SingleClientConnManager implements ClientConnectionManager { } } catch (IOException iox) { if (log.isDebugEnabled()) { - log.debug("Exception shutting down released connection.", + log.debug("Exception shutting down released connection.", iox); - } + } } finally { sca.detach(); synchronized (this) { managedConn = null; lastReleaseTime = System.currentTimeMillis(); if(validDuration > 0) { - connectionExpiresTime = timeUnit.toMillis(validDuration) + lastReleaseTime; - } else { - connectionExpiresTime = Long.MAX_VALUE; - } + connectionExpiresTime = timeUnit.toMillis(validDuration) + lastReleaseTime; + } else { + connectionExpiresTime = Long.MAX_VALUE; + } } } } @@ -341,8 +341,8 @@ public class SingleClientConnManager implements ClientConnectionManager { synchronized (this) { try { if (uniquePoolEntry != null) { - uniquePoolEntry.shutdown(); - } + uniquePoolEntry.shutdown(); + } } catch (IOException iox) { // ignore log.debug("Problem while shutting down manager.", iox); @@ -356,8 +356,8 @@ public class SingleClientConnManager implements ClientConnectionManager { protected void revokeConnection() { ConnAdapter conn = managedConn; if (conn == null) { - return; - } + return; + } conn.detach(); synchronized (this) { @@ -389,8 +389,8 @@ public class SingleClientConnManager implements ClientConnectionManager { protected void close() throws IOException { shutdownEntry(); if (connection.isOpen()) { - connection.close(); - } + connection.close(); + } } /** @@ -399,8 +399,8 @@ public class SingleClientConnManager implements ClientConnectionManager { protected void shutdown() throws IOException { shutdownEntry(); if (connection.isOpen()) { - connection.shutdown(); - } + connection.shutdown(); + } } } diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java index 159e8ca63..e99ac32ad 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/AbstractConnPool.java @@ -195,8 +195,8 @@ public abstract class AbstractConnPool { try { if (isShutDown) { - return; - } + return; + } // close all connections that are issued to an application Iterator iter = leasedConnections.iterator(); diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java index c64e71289..097b89c93 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ConnPoolByRoute.java @@ -500,9 +500,9 @@ public class ConnPoolByRoute extends AbstractConnPool { // If the free entry isn't valid anymore, get rid of it // and loop to find another one that might be valid. if (log.isDebugEnabled()) { - log.debug("Closing expired free connection" + log.debug("Closing expired free connection" + " [" + rospl.getRoute() + "][" + state + "]"); - } + } closeConnection(entry); // We use dropEntry instead of deleteEntry because the entry // is no longer "free" (we just allocated it), and deleteEntry diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java index abc5e5ef2..85ce582a1 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/RouteSpecificPool.java @@ -243,8 +243,8 @@ public class RouteSpecificPool { final boolean found = freeEntries.remove(entry); if (found) { - numEntries--; - } + numEntries--; + } return found; } @@ -303,8 +303,8 @@ public class RouteSpecificPool { */ public void removeThread(final WaitingThread wt) { if (wt == null) { - return; - } + return; + } this.waitingThreads.remove(wt); } diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java index d1314c21c..7146152fc 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/ThreadSafeClientConnManager.java @@ -271,9 +271,9 @@ public class ThreadSafeClientConnManager implements ClientConnectionManager { } } catch (IOException iox) { if (log.isDebugEnabled()) { - log.debug("Exception shutting down released connection.", + log.debug("Exception shutting down released connection.", iox); - } + } } finally { boolean reusable = hca.isMarkedReusable(); if (log.isDebugEnabled()) { diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java index 9c05df936..1a9349591 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThread.java @@ -146,8 +146,8 @@ public class WaitingThread { } if (aborted) { - throw new InterruptedException("Operation interrupted"); - } + throw new InterruptedException("Operation interrupted"); + } this.waiter = Thread.currentThread(); @@ -160,8 +160,8 @@ public class WaitingThread { success = true; } if (aborted) { - throw new InterruptedException("Operation interrupted"); - } + throw new InterruptedException("Operation interrupted"); + } } finally { this.waiter = null; } diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThreadAborter.java b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThreadAborter.java index dc5c0b7a7..72b99c9ab 100644 --- a/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThreadAborter.java +++ b/httpclient/src/main/java/org/apache/http/impl/conn/tsccm/WaitingThreadAborter.java @@ -48,8 +48,8 @@ public class WaitingThreadAborter { aborted = true; if (waitingThread != null) { - waitingThread.interrupt(); - } + waitingThread.interrupt(); + } } @@ -62,8 +62,8 @@ public class WaitingThreadAborter { public void setWaitingThread(final WaitingThread waitingThread) { this.waitingThread = waitingThread; if (aborted) { - waitingThread.interrupt(); - } + waitingThread.interrupt(); + } } } diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java b/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java index 00ec8b383..3dca0bc9e 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/DateUtils.java @@ -157,8 +157,8 @@ public final class DateUtils { ParsePosition pos = new ParsePosition(0); Date result = dateParser.parse(dateValue, pos); if (pos.getIndex() != 0) { - return result; - } + return result; + } } // we were unable to parse the date diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java index a9623bffb..7d9c75d4b 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixFilter.java @@ -80,8 +80,8 @@ public class PublicSuffixFilter implements CookieAttributeHandler { */ public boolean match(final Cookie cookie, final CookieOrigin origin) { if (isForPublicSuffix(cookie)) { - return false; - } + return false; + } return wrapped.match(cookie, origin); } @@ -96,34 +96,34 @@ public class PublicSuffixFilter implements CookieAttributeHandler { private boolean isForPublicSuffix(final Cookie cookie) { String domain = cookie.getDomain(); if (domain.startsWith(".")) { - domain = domain.substring(1); - } + domain = domain.substring(1); + } domain = Punycode.toUnicode(domain); // An exception rule takes priority over any other matching rule. if (this.exceptions != null) { if (this.exceptions.contains(domain)) { - return false; - } + return false; + } } if (this.suffixes == null) { - return false; - } + return false; + } do { if (this.suffixes.contains(domain)) { - return true; - } + return true; + } // patterns if (domain.startsWith("*.")) { - domain = domain.substring(2); - } + domain = domain.substring(2); + } int nextdot = domain.indexOf('.'); if (nextdot == -1) { - break; - } + break; + } domain = "*" + domain.substring(nextdot); } while (domain.length() > 0); diff --git a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java index 4b3ca8952..5fea84276 100644 --- a/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java +++ b/httpclient/src/main/java/org/apache/http/impl/cookie/PublicSuffixListParser.java @@ -67,21 +67,21 @@ public class PublicSuffixListParser { more = readLine(r, sb); String line = sb.toString(); if (line.length() == 0) { - continue; - } + continue; + } if (line.startsWith("//")) - { - continue; //entire lines can also be commented using // - } + { + continue; //entire lines can also be commented using // + } if (line.startsWith(".")) - { - line = line.substring(1); // A leading dot is optional - } + { + line = line.substring(1); // A leading dot is optional + } // An exclamation mark (!) at the start of a rule marks an exception to a previous wildcard rule boolean isException = line.startsWith("!"); if (isException) { - line = line.substring(1); - } + line = line.substring(1); + } if (isException) { exceptions.add(line); @@ -108,19 +108,19 @@ public class PublicSuffixListParser { while ((b = r.read()) != -1) { char c = (char) b; if (c == '\n') { - break; - } + break; + } // Each line is only read up to the first whitespace if (Character.isWhitespace(c)) { - hitWhitespace = true; - } + hitWhitespace = true; + } if (!hitWhitespace) { - sb.append(c); - } + sb.append(c); + } if (sb.length() > MAX_LINE_LEN) - { - throw new IOException("Line too long"); // prevent excess memory usage - } + { + throw new IOException("Line too long"); // prevent excess memory usage + } } return (b != -1); } diff --git a/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java b/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java index ac67bf449..d47d8b8b0 100644 --- a/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java +++ b/httpclient/src/main/java/org/apache/http/impl/execchain/BackoffStrategyExec.java @@ -83,14 +83,14 @@ public class BackoffStrategyExec implements ClientExecChain { this.backoffManager.backOff(route); } if (ex instanceof RuntimeException) { - throw (RuntimeException) ex; - } + throw (RuntimeException) ex; + } if (ex instanceof HttpException) { - throw (HttpException) ex; - } + throw (HttpException) ex; + } if (ex instanceof IOException) { - throw (IOException) ex; - } + throw (IOException) ex; + } throw new UndeclaredThrowableException(ex); } if (this.connectionBackoffStrategy.shouldBackoff(out)) { diff --git a/httpclient/src/test/java/org/apache/http/conn/TestScheme.java b/httpclient/src/test/java/org/apache/http/conn/TestScheme.java index 535ea99aa..f49b17a6f 100644 --- a/httpclient/src/test/java/org/apache/http/conn/TestScheme.java +++ b/httpclient/src/test/java/org/apache/http/conn/TestScheme.java @@ -138,12 +138,12 @@ public class TestScheme { String name = names.get(0); if ("http".equals(name)) { - flaghttp = true; - } else if ("https".equals(name)) { - flaghttps = true; - } else { - Assert.fail("unexpected name in iterator: " + name); - } + flaghttp = true; + } else if ("https".equals(name)) { + flaghttps = true; + } else { + Assert.fail("unexpected name in iterator: " + name); + } Assert.assertNotNull(schmreg.get(name)); schmreg.unregister(name); @@ -153,12 +153,12 @@ public class TestScheme { if ("http".equals(name)) { if (flaghttp) { - Assert.fail("name 'http' found twice"); - } + Assert.fail("name 'http' found twice"); + } } else if ("https".equals(name)) { if (flaghttps) { - Assert.fail("name 'https' found twice"); - } + Assert.fail("name 'https' found twice"); + } } else { Assert.fail("unexpected name in iterator: " + name); } diff --git a/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java b/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java index 2cc1f6b5c..513768113 100644 --- a/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java +++ b/httpclient/src/test/java/org/apache/http/conn/routing/TestRouteTracker.java @@ -692,8 +692,8 @@ public class TestRouteTracker { */ public final static String checkToString(final RouteTracker rt) { if (rt == null) { - return null; - } + return null; + } final String rts = rt.toString(); diff --git a/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java b/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java index 0b082b5f8..a825fdd79 100644 --- a/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java +++ b/httpclient/src/test/java/org/apache/http/impl/auth/TestNTLMEngineImpl.java @@ -48,8 +48,8 @@ public class TestNTLMEngineImpl { /* Test suite helper */ static byte toNibble(final char c) { if (c >= 'a' && c <= 'f') { - return (byte) (c - 'a' + 0x0a); - } + return (byte) (c - 'a' + 0x0a); + } return (byte) (c - '0'); } @@ -73,14 +73,14 @@ public class TestNTLMEngineImpl { byte[] answer = md4.getOutput(); byte[] correctAnswer = toBytes(hexOutput); if (answer.length != correctAnswer.length) { - throw new Exception("Answer length disagrees for MD4('" + input + "')"); - } + throw new Exception("Answer length disagrees for MD4('" + input + "')"); + } int i = 0; while (i < answer.length) { if (answer[i] != correctAnswer[i]) { - throw new Exception("Answer value for MD4('" + input + "') disagrees at position " + throw new Exception("Answer value for MD4('" + input + "') disagrees at position " + Integer.toString(i)); - } + } i++; } } diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java b/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java index 427ffc96f..c37335bba 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/TestAIMDBackoffManager.java @@ -160,11 +160,11 @@ public class TestAIMDBackoffManager { public void coolDownPeriodIsConfigurable() { long cd = new Random().nextLong() / 2; if (cd < 0) { - cd *= -1; - } + cd *= -1; + } if (cd < 1) { - cd++; - } + cd++; + } long now = System.currentTimeMillis(); impl.setCooldownMillis(cd); clock.setCurrentTime(now); diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java b/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java index 3a0611953..315431fca 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/TestDecompressingHttpClient.java @@ -156,11 +156,11 @@ public class TestDecompressingHttpClient { for(Header h : captured.getHeaders("Accept-Encoding")) { for(HeaderElement elt : h.getElements()) { if ("gzip".equals(elt.getName())) { - foundGzip = true; - } + foundGzip = true; + } if ("deflate".equals(elt.getName())) { - foundDeflate = true; - } + foundDeflate = true; + } } } assertTrue(foundGzip); diff --git a/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java b/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java index e29415fb6..fc1dee206 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/TestDefaultBackoffStrategy.java @@ -82,8 +82,8 @@ public class TestDefaultBackoffStrategy { public void doesNotBackOffForNon503StatusCodes() { for(int i = 100; i <= 599; i++) { if (i == HttpStatus.SC_SERVICE_UNAVAILABLE) { - continue; - } + continue; + } HttpResponse resp = new BasicHttpResponse(HttpVersion.HTTP_1_1, i, "Foo"); assertFalse(impl.shouldBackoff(resp)); diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java index 5bd49ede4..0e0a26ac0 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestAbortHandling.java @@ -216,8 +216,8 @@ public class TestAbortHandling extends IntegrationTestBase { try { try { if(!startLatch.await(1, TimeUnit.SECONDS)) { - throw new RuntimeException("Took too long to start!"); - } + throw new RuntimeException("Took too long to start!"); + } } catch(InterruptedException interrupted) { throw new RuntimeException("Never started!", interrupted); } @@ -376,12 +376,12 @@ public class TestAbortHandling extends IntegrationTestBase { // zero usually means sleep forever, but CountDownLatch doesn't interpret it that way. if(timeout == 0) { - timeout = Integer.MAX_VALUE; - } + timeout = Integer.MAX_VALUE; + } if(!awaitLatch.await(timeout, tunit)) { - throw new ConnectionPoolTimeoutException(); - } + throw new ConnectionPoolTimeoutException(); + } return Mockito.mock(HttpClientConnection.class); } @@ -436,12 +436,12 @@ public class TestAbortHandling extends IntegrationTestBase { // zero usually means sleep forever, but CountDownLatch doesn't interpret it that way. if(timeout == 0) { - timeout = Integer.MAX_VALUE; - } + timeout = Integer.MAX_VALUE; + } if(!awaitLatch.await(timeout, tunit)) { - throw new ConnectionPoolTimeoutException(); - } + throw new ConnectionPoolTimeoutException(); + } return Mockito.mock(HttpClientConnection.class); } @@ -491,8 +491,8 @@ public class TestAbortHandling extends IntegrationTestBase { public void setCancellable(final Cancellable cancellable) { try { if(!releaseTriggerLatch.await(1, TimeUnit.SECONDS)) { - throw new RuntimeException("Waited too long..."); - } + throw new RuntimeException("Waited too long..."); + } } catch(InterruptedException ie) { throw new RuntimeException(ie); } diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java index 3a7cefc39..1ec4d7da2 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestConnectionManagement.java @@ -463,8 +463,8 @@ public class TestConnectionManagement extends LocalServerTestBase { abortingThread.join(5000); if(throwRef.get() != null) { - throw new RuntimeException(throwRef.get()); - } + throw new RuntimeException(throwRef.get()); + } Assert.assertFalse(conn.isOpen()); Assert.assertEquals(0, localServer.getAcceptedConnectionCount()); @@ -518,8 +518,8 @@ public class TestConnectionManagement extends LocalServerTestBase { abortingThread.join(5000); if(throwRef.get() != null) { - throw new RuntimeException(throwRef.get()); - } + throw new RuntimeException(throwRef.get()); + } Assert.assertFalse(conn.isOpen()); Assert.assertEquals(0, localServer.getAcceptedConnectionCount()); @@ -573,16 +573,16 @@ public class TestConnectionManagement extends LocalServerTestBase { abortingThread.join(5000); if(throwRef.get() != null) { - throw new RuntimeException(throwRef.get()); - } + throw new RuntimeException(throwRef.get()); + } Assert.assertFalse(conn.isOpen()); // Give the server a bit of time to accept the connection, but // ensure that it can accept it. for(int i = 0; i < 10; i++) { if(localServer.getAcceptedConnectionCount() == 1) { - break; - } + break; + } Thread.sleep(100); } Assert.assertEquals(1, localServer.getAcceptedConnectionCount()); @@ -608,16 +608,16 @@ public class TestConnectionManagement extends LocalServerTestBase { void waitForState() throws InterruptedException { if(!waitLatch.await(1, TimeUnit.SECONDS)) { - throw new RuntimeException("waited too long"); - } + throw new RuntimeException("waited too long"); + } } void latch() { waitLatch.countDown(); try { if (!continueLatch.await(60, TimeUnit.SECONDS)) { - throw new RuntimeException("waited too long!"); - } + throw new RuntimeException("waited too long!"); + } } catch (InterruptedException e) { throw new RuntimeException(e); } @@ -644,23 +644,23 @@ public class TestConnectionManagement extends LocalServerTestBase { final InetSocketAddress localAddress, final HttpContext context) throws IOException, ConnectTimeoutException { if(waitPolicy == WaitPolicy.BEFORE_CONNECT) { - latch(); - } + latch(); + } Socket socket = delegate.connectSocket( connectTimeout, sock, host, remoteAddress, localAddress, context); if(waitPolicy == WaitPolicy.AFTER_CONNECT) { - latch(); - } + latch(); + } return socket; } public Socket createSocket(final HttpContext context) throws IOException { if(waitPolicy == WaitPolicy.BEFORE_CREATE) { - latch(); - } + latch(); + } return delegate.createSocket(context); } diff --git a/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java b/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java index 0b0a8add9..c433a7a2f 100644 --- a/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java +++ b/httpclient/src/test/java/org/apache/http/localserver/EchoHandler.java @@ -83,8 +83,8 @@ public class EchoHandler HttpEntity entity = null; if (request instanceof HttpEntityEnclosingRequest) { - entity = ((HttpEntityEnclosingRequest)request).getEntity(); - } + entity = ((HttpEntityEnclosingRequest)request).getEntity(); + } // For some reason, just putting the incoming entity into // the response will not work. We have to buffer the message. diff --git a/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java b/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java index 2448d33bc..40fec2dc9 100644 --- a/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java +++ b/httpclient/src/test/java/org/apache/http/localserver/LocalTestServer.java @@ -273,10 +273,10 @@ public class LocalTestServer { StringBuilder sb = new StringBuilder(80); sb.append("LocalTestServer/"); if (ssock == null) { - sb.append("stopped"); - } else { - sb.append(ssock.getLocalSocketAddress()); - } + sb.append("stopped"); + } else { + sb.append(ssock.getLocalSocketAddress()); + } return sb.toString(); }