diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java index b56ad3bbe..2a0d1a971 100644 --- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java +++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/DefaultFailureCache.java @@ -130,7 +130,7 @@ public class DefaultFailureCache implements FailureCache { private FailureCacheValue findValueWithOldestTimestamp() { long oldestTimestamp = Long.MAX_VALUE; FailureCacheValue oldestValue = null; - for (Map.Entry storageEntry : storage.entrySet()) { + for (final Map.Entry storageEntry : storage.entrySet()) { final FailureCacheValue value = storageEntry.getValue(); final long creationTimeInNanos = value.getCreationTimeInNanos(); if (creationTimeInNanos < oldestTimestamp) { diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java index bce61eebe..0a4abf287 100644 --- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java +++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestStaleWhileRevalidationReleasesConnection.java @@ -114,14 +114,14 @@ public class TestStaleWhileRevalidationReleasesConnection { if (this.localServer != null) { try { this.localServer.stop(); - } catch(Exception e) { + } catch(final Exception e) { e.printStackTrace(); } } try { client.close(); - } catch(IOException e) { + } catch(final IOException e) { e.printStackTrace(); } } @@ -141,7 +141,7 @@ public class TestStaleWhileRevalidationReleasesConnection { try { Thread.sleep(1000); - } catch (Exception e) { + } catch (final Exception e) { } // These will be cached @@ -160,7 +160,7 @@ public class TestStaleWhileRevalidationReleasesConnection { // wait, so that max-age is expired try { Thread.sleep(4000); - } catch (Exception e) { + } catch (final Exception e) { } @@ -173,7 +173,7 @@ public class TestStaleWhileRevalidationReleasesConnection { try { Thread.sleep(1000); - } catch (Exception e) { + } catch (final Exception e) { } @@ -197,16 +197,16 @@ public class TestStaleWhileRevalidationReleasesConnection { try { response = cachingClient.execute(httpget, localContext); return null; - } catch (ClientProtocolException e1) { + } catch (final ClientProtocolException e1) { return e1; - } catch (IOException e1) { + } catch (final IOException e1) { return e1; } finally { if(response!=null) { final HttpEntity entity = response.getEntity(); try { EntityUtils.consume(entity); - } catch (IOException e) { + } catch (final IOException e) { e.printStackTrace(); } } @@ -284,7 +284,7 @@ public class TestStaleWhileRevalidationReleasesConnection { if(contentHeader!=null) { try { return contentHeader.getValue().getBytes("UTF-8"); - } catch(UnsupportedEncodingException e) { + } catch(final UnsupportedEncodingException e) { return contentHeader.getValue().getBytes(); } } else { diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java b/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java index 482c5b508..e717ebb5f 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/AbstractVerifier.java @@ -388,7 +388,7 @@ public abstract class AbstractVerifier implements X509HostnameVerifier { try { final InetAddress inetAddress = InetAddress.getByName(hostname); return inetAddress.getHostAddress(); - } catch (UnknownHostException uhe) { // Should not happen, because we check for IPv6 address above + } catch (final UnknownHostException uhe) { // Should not happen, because we check for IPv6 address above log.error("Unexpected error converting "+hostname, uhe); return hostname; } diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLContextBuilder.java b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLContextBuilder.java index 99173bc23..5d81fdaa9 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLContextBuilder.java +++ b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLContextBuilder.java @@ -112,7 +112,7 @@ public class SSLContextBuilder { } } } - for (TrustManager tm : tms) { + for (final TrustManager tm : tms) { this.trustmanagers.add(tm); } } @@ -151,7 +151,7 @@ public class SSLContextBuilder { } } } - for (KeyManager km : kms) { + for (final KeyManager km : kms) { keymanagers.add(km); } } @@ -216,10 +216,10 @@ public class SSLContextBuilder { public String chooseClientAlias( final String[] keyTypes, final Principal[] issuers, final Socket socket) { final Map validAliases = new HashMap(); - for (String keyType: keyTypes) { + for (final String keyType: keyTypes) { final String[] aliases = this.keyManager.getClientAliases(keyType, issuers); if (aliases != null) { - for (String alias: aliases) { + for (final String alias: aliases) { validAliases.put(alias, new PrivateKeyDetails(keyType, this.keyManager.getCertificateChain(alias))); } @@ -238,7 +238,7 @@ public class SSLContextBuilder { final Map validAliases = new HashMap(); final String[] aliases = this.keyManager.getServerAliases(keyType, issuers); if (aliases != null) { - for (String alias: aliases) { + for (final String alias: aliases) { validAliases.put(alias, new PrivateKeyDetails(keyType, this.keyManager.getCertificateChain(alias))); } 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 435915b9e..077cf26bc 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 @@ -75,7 +75,7 @@ final class NTLMEngineImpl implements NTLMEngine { java.security.SecureRandom rnd = null; try { rnd = java.security.SecureRandom.getInstance("SHA1PRNG"); - } catch (Exception ignore) { + } catch (final Exception ignore) { } RND_GEN = rnd; } @@ -529,7 +529,7 @@ final class NTLMEngineImpl implements NTLMEngine { lanManagerSessionKey = new byte[16]; System.arraycopy(lowPart, 0, lanManagerSessionKey, 0, lowPart.length); System.arraycopy(highPart, 0, lanManagerSessionKey, lowPart.length, highPart.length); - } catch (Exception e) { + } catch (final Exception e) { throw new NTLMEngineException(e.getMessage(), e); } } @@ -552,7 +552,7 @@ final class NTLMEngineImpl implements NTLMEngine { final Cipher rc4 = Cipher.getInstance("RC4"); rc4.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "RC4")); return rc4.doFinal(value); - } catch (Exception e) { + } catch (final Exception e) { throw new NTLMEngineException(e.getMessage(), e); } } @@ -589,7 +589,7 @@ final class NTLMEngineImpl implements NTLMEngine { final byte[] sessionHash = new byte[8]; System.arraycopy(digest, 0, sessionHash, 0, 8); return lmResponse(ntlmHash, sessionHash); - } catch (Exception e) { + } catch (final Exception e) { if (e instanceof NTLMEngineException) { throw (NTLMEngineException) e; } @@ -624,7 +624,7 @@ final class NTLMEngineImpl implements NTLMEngine { System.arraycopy(lowHash, 0, lmHash, 0, 8); System.arraycopy(highHash, 0, lmHash, 8, 8); return lmHash; - } catch (Exception e) { + } catch (final Exception e) { throw new NTLMEngineException(e.getMessage(), e); } } @@ -644,7 +644,7 @@ final class NTLMEngineImpl implements NTLMEngine { final MD4 md4 = new MD4(); md4.update(unicodePassword); return md4.getOutput(); - } catch (UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new NTLMEngineException("Unicode not supported: " + e.getMessage(), e); } } @@ -665,7 +665,7 @@ final class NTLMEngineImpl implements NTLMEngine { hmacMD5.update(domain.toUpperCase(Locale.US).getBytes("UnicodeLittleUnmarked")); } return hmacMD5.getOutput(); - } catch (UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new NTLMEngineException("Unicode not supported! " + e.getMessage(), e); } } @@ -686,7 +686,7 @@ final class NTLMEngineImpl implements NTLMEngine { hmacMD5.update(domain.getBytes("UnicodeLittleUnmarked")); } return hmacMD5.getOutput(); - } catch (UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new NTLMEngineException("Unicode not supported! " + e.getMessage(), e); } } @@ -720,7 +720,7 @@ final class NTLMEngineImpl implements NTLMEngine { System.arraycopy(middleResponse, 0, lmResponse, 8, 8); System.arraycopy(highResponse, 0, lmResponse, 16, 8); return lmResponse; - } catch (Exception e) { + } catch (final Exception e) { throw new NTLMEngineException(e.getMessage(), e); } } @@ -1010,7 +1010,7 @@ final class NTLMEngineImpl implements NTLMEngine { hostBytes = unqualifiedHost != null? unqualifiedHost.getBytes("ASCII") : null; domainBytes = unqualifiedDomain != null ? unqualifiedDomain .toUpperCase(Locale.US).getBytes("ASCII") : null; - } catch (UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new NTLMEngineException("Unicode unsupported: " + e.getMessage(), e); } } @@ -1134,7 +1134,7 @@ final class NTLMEngineImpl implements NTLMEngine { if (bytes.length != 0) { try { target = new String(bytes, "UnicodeLittleUnmarked"); - } catch (UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new NTLMEngineException(e.getMessage(), e); } } @@ -1239,7 +1239,7 @@ final class NTLMEngineImpl implements NTLMEngine { } } } - } catch (NTLMEngineException e) { + } catch (final NTLMEngineException e) { // This likely means we couldn't find the MD4 hash algorithm - // fail back to just using LM ntResp = new byte[0]; @@ -1267,7 +1267,7 @@ final class NTLMEngineImpl implements NTLMEngine { domainBytes = unqualifiedDomain != null ? unqualifiedDomain .toUpperCase(Locale.US).getBytes("UnicodeLittleUnmarked") : null; userBytes = user.getBytes("UnicodeLittleUnmarked"); - } catch (UnsupportedEncodingException e) { + } catch (final UnsupportedEncodingException e) { throw new NTLMEngineException("Unicode not supported: " + e.getMessage(), e); } } @@ -1594,7 +1594,7 @@ final class NTLMEngineImpl implements NTLMEngine { byte[] key = input; try { md5 = MessageDigest.getInstance("MD5"); - } catch (Exception ex) { + } catch (final Exception ex) { // Umm, the algorithm doesn't exist - throw an // NTLMEngineException! throw new NTLMEngineException( diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java index ec20288d8..9ae609dff 100644 --- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java +++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestRedirects.java @@ -640,7 +640,7 @@ public class TestRedirects extends IntegrationTestBase { try { this.httpclient.execute(target, httpget); - } catch (ClientProtocolException ex) { + } catch (final ClientProtocolException ex) { final Throwable cause = ex.getCause(); Assert.assertTrue(cause instanceof HttpException); throw ex; diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java index 6f79dd8cf..1fb70c91e 100644 --- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java +++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestMainClientExec.java @@ -378,7 +378,7 @@ public class TestMainClientExec { Mockito.when(execAware.isAborted()).thenReturn(Boolean.TRUE); try { mainClientExec.execute(route, request, context, execAware); - } catch (IOException ex) { + } catch (final IOException ex) { Mockito.verify(connRequest, Mockito.times(1)).cancel(); throw ex; } @@ -394,7 +394,7 @@ public class TestMainClientExec { Mockito.when(execAware.isAborted()).thenReturn(Boolean.FALSE, Boolean.TRUE); try { mainClientExec.execute(route, request, context, execAware); - } catch (IOException ex) { + } catch (final IOException ex) { Mockito.verify(connRequest, Mockito.times(1)).get(0, TimeUnit.MILLISECONDS); Mockito.verify(execAware, Mockito.times(2)).setCancellable(Mockito.any()); Mockito.verify(connManager, Mockito.never()).connect( @@ -416,7 +416,7 @@ public class TestMainClientExec { Mockito.when(execAware.isAborted()).thenReturn(Boolean.FALSE, Boolean.FALSE, Boolean.TRUE); try { mainClientExec.execute(route, request, context, execAware); - } catch (IOException ex) { + } catch (final IOException ex) { Mockito.verify(connRequest, Mockito.times(1)).get(0, TimeUnit.MILLISECONDS); Mockito.verify(connManager, Mockito.times(1)).connect(managedConn, route, 0, context); Mockito.verify(requestExecutor, Mockito.never()).execute( @@ -596,7 +596,7 @@ public class TestMainClientExec { try { mainClientExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(connManager).releaseConnection(managedConn, null, 0, TimeUnit.MILLISECONDS); throw ex; @@ -616,7 +616,7 @@ public class TestMainClientExec { try { mainClientExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(connManager).releaseConnection(managedConn, null, 0, TimeUnit.MILLISECONDS); throw ex; @@ -636,7 +636,7 @@ public class TestMainClientExec { try { mainClientExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(connManager).releaseConnection(managedConn, null, 0, TimeUnit.MILLISECONDS); throw ex; @@ -741,7 +741,7 @@ public class TestMainClientExec { try { mainClientExec.establishRoute(authState, managedConn, route, request, context); - } catch (TunnelRefusedException ex) { + } catch (final TunnelRefusedException ex) { final HttpResponse r = ex.getResponse(); Assert.assertEquals("Ka-boom", EntityUtils.toString(r.getEntity())); diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestMinimalClientExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestMinimalClientExec.java index cc5143130..c9028d6b1 100644 --- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestMinimalClientExec.java +++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestMinimalClientExec.java @@ -248,7 +248,7 @@ public class TestMinimalClientExec { Mockito.when(execAware.isAborted()).thenReturn(Boolean.TRUE); try { minimalClientExec.execute(route, request, context, execAware); - } catch (IOException ex) { + } catch (final IOException ex) { Mockito.verify(connRequest, Mockito.times(1)).cancel(); throw ex; } @@ -292,7 +292,7 @@ public class TestMinimalClientExec { try { minimalClientExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(connManager).releaseConnection(managedConn, null, 0, TimeUnit.MILLISECONDS); throw ex; @@ -312,7 +312,7 @@ public class TestMinimalClientExec { try { minimalClientExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(connManager).releaseConnection(managedConn, null, 0, TimeUnit.MILLISECONDS); throw ex; @@ -332,7 +332,7 @@ public class TestMinimalClientExec { try { minimalClientExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(connManager).releaseConnection(managedConn, null, 0, TimeUnit.MILLISECONDS); throw ex; diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestProtocolExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestProtocolExec.java index 75427cd74..bfb98807f 100644 --- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestProtocolExec.java +++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestProtocolExec.java @@ -211,7 +211,7 @@ public class TestProtocolExec { Mockito.same(response), Mockito.any()); try { protocolExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(response).close(); throw ex; } @@ -233,7 +233,7 @@ public class TestProtocolExec { Mockito.same(response), Mockito.any()); try { protocolExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(response).close(); throw ex; } @@ -255,7 +255,7 @@ public class TestProtocolExec { Mockito.same(response), Mockito.any()); try { protocolExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(response).close(); throw ex; } diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java index 85289f4b9..a1bcc1e86 100644 --- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java +++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestRedirectExec.java @@ -306,7 +306,7 @@ public class TestRedirectExec { try { redirectExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(response1).close(); throw ex; } @@ -341,7 +341,7 @@ public class TestRedirectExec { try { redirectExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(instream1).close(); Mockito.verify(response1).close(); throw ex; diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestRetryExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestRetryExec.java index df652e8bb..177d5be9f 100644 --- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestRetryExec.java +++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestRetryExec.java @@ -104,7 +104,7 @@ public class TestRetryExec { Mockito.any())).thenReturn(Boolean.TRUE); try { retryExec.execute(route, request, context, execAware); - } catch (IOException ex) { + } catch (final IOException ex) { Mockito.verify(requestExecutor, Mockito.times(2)).execute( Mockito.eq(route), Mockito.same(request), @@ -130,7 +130,7 @@ public class TestRetryExec { Mockito.when(execAware.isAborted()).thenReturn(Boolean.TRUE); try { retryExec.execute(route, request, context, execAware); - } catch (IOException ex) { + } catch (final IOException ex) { Mockito.verify(requestExecutor, Mockito.times(1)).execute( Mockito.eq(route), Mockito.same(request), @@ -175,7 +175,7 @@ public class TestRetryExec { Mockito.any())).thenReturn(Boolean.TRUE); try { retryExec.execute(route, request, context, execAware); - } catch (IOException ex) { + } catch (final IOException ex) { Mockito.verify(requestExecutor, Mockito.times(1)).execute( Mockito.eq(route), Mockito.same(request), diff --git a/httpclient/src/test/java/org/apache/http/impl/execchain/TestServiceUnavailableRetryExec.java b/httpclient/src/test/java/org/apache/http/impl/execchain/TestServiceUnavailableRetryExec.java index 5d439bd00..a705c950f 100644 --- a/httpclient/src/test/java/org/apache/http/impl/execchain/TestServiceUnavailableRetryExec.java +++ b/httpclient/src/test/java/org/apache/http/impl/execchain/TestServiceUnavailableRetryExec.java @@ -109,7 +109,7 @@ public class TestServiceUnavailableRetryExec { Mockito.any()); try { retryExec.execute(route, request, context, execAware); - } catch (Exception ex) { + } catch (final Exception ex) { Mockito.verify(response).close(); throw ex; }