Add final modifier to local variables (exception catch).
git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1558064 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
54667c0a43
commit
fe84b2934c
|
@ -130,7 +130,7 @@ public class DefaultFailureCache implements FailureCache {
|
|||
private FailureCacheValue findValueWithOldestTimestamp() {
|
||||
long oldestTimestamp = Long.MAX_VALUE;
|
||||
FailureCacheValue oldestValue = null;
|
||||
for (Map.Entry<String, FailureCacheValue> storageEntry : storage.entrySet()) {
|
||||
for (final Map.Entry<String, FailureCacheValue> storageEntry : storage.entrySet()) {
|
||||
final FailureCacheValue value = storageEntry.getValue();
|
||||
final long creationTimeInNanos = value.getCreationTimeInNanos();
|
||||
if (creationTimeInNanos < oldestTimestamp) {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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<String, PrivateKeyDetails> validAliases = new HashMap<String, PrivateKeyDetails>();
|
||||
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<String, PrivateKeyDetails> validAliases = new HashMap<String, PrivateKeyDetails>();
|
||||
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)));
|
||||
}
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.<Cancellable>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()));
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -211,7 +211,7 @@ public class TestProtocolExec {
|
|||
Mockito.same(response), Mockito.<HttpContext>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.<HttpContext>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.<HttpContext>any());
|
||||
try {
|
||||
protocolExec.execute(route, request, context, execAware);
|
||||
} catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
Mockito.verify(response).close();
|
||||
throw ex;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -104,7 +104,7 @@ public class TestRetryExec {
|
|||
Mockito.<HttpContext>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.<HttpContext>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),
|
||||
|
|
|
@ -109,7 +109,7 @@ public class TestServiceUnavailableRetryExec {
|
|||
Mockito.<HttpContext>any());
|
||||
try {
|
||||
retryExec.execute(route, request, context, execAware);
|
||||
} catch (Exception ex) {
|
||||
} catch (final Exception ex) {
|
||||
Mockito.verify(response).close();
|
||||
throw ex;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue