Checkstyle fixes: Use final and tab police.

This commit is contained in:
Gary Gregory 2017-07-12 17:29:17 -07:00
parent 6156eb1f0f
commit 61529d1f88
15 changed files with 1245 additions and 1245 deletions

View File

@ -387,7 +387,7 @@ public class CachingHttpClient implements HttpClient {
private <T> T handleAndConsume( private <T> T handleAndConsume(
final ResponseHandler<? extends T> responseHandler, final ResponseHandler<? extends T> responseHandler,
final HttpResponse response) throws Error, IOException { final HttpResponse response) throws Error, IOException {
T result; final T result;
try { try {
result = responseHandler.handleResponse(response); result = responseHandler.handleResponse(response);
} catch (final Exception t) { } catch (final Exception t) {
@ -429,7 +429,7 @@ public class CachingHttpClient implements HttpClient {
public HttpResponse execute(final HttpHost target, final HttpRequest originalRequest, final HttpContext context) public HttpResponse execute(final HttpHost target, final HttpRequest originalRequest, final HttpContext context)
throws IOException { throws IOException {
HttpRequestWrapper request; final HttpRequestWrapper request;
if (originalRequest instanceof HttpRequestWrapper) { if (originalRequest instanceof HttpRequestWrapper) {
request = ((HttpRequestWrapper) originalRequest); request = ((HttpRequestWrapper) originalRequest);
} else { } else {
@ -693,7 +693,7 @@ public class CachingHttpClient implements HttpClient {
final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader()); final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader());
final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE;
String value; final String value;
if ("http".equalsIgnoreCase(pv.getProtocol())) { if ("http".equalsIgnoreCase(pv.getProtocol())) {
value = String.format("%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getMajor(), pv.getMinor(), value = String.format("%d.%d localhost (Apache-HttpClient/%s (cache))", pv.getMajor(), pv.getMinor(),
release); release);

View File

@ -155,7 +155,7 @@ class CacheKeyGenerator {
} }
Collections.sort(variantHeaderNames); Collections.sort(variantHeaderNames);
StringBuilder buf; final StringBuilder buf;
try { try {
buf = new StringBuilder("{"); buf = new StringBuilder("{");
boolean first = true; boolean first = true;

View File

@ -527,7 +527,7 @@ public class CachingExec implements ClientExecChain {
final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader()); final VersionInfo vi = VersionInfo.loadVersionInfo("org.apache.http.client", getClass().getClassLoader());
final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE; final String release = (vi != null) ? vi.getRelease() : VersionInfo.UNAVAILABLE;
String value; final String value;
final int major = pv.getMajor(); final int major = pv.getMajor();
final int minor = pv.getMinor(); final int minor = pv.getMinor();
if ("http".equalsIgnoreCase(pv.getProtocol())) { if ("http".equalsIgnoreCase(pv.getProtocol())) {

View File

@ -68,7 +68,7 @@ public class HeapResourceFactory implements ResourceFactory {
public Resource copy( public Resource copy(
final String requestId, final String requestId,
final Resource resource) throws IOException { final Resource resource) throws IOException {
byte[] body; final byte[] body;
if (resource instanceof HeapResource) { if (resource instanceof HeapResource) {
body = ((HeapResource) resource).getByteArray(); body = ((HeapResource) resource).getByteArray();
} else { } else {

View File

@ -58,7 +58,7 @@ public class MemcachedCacheEntryImpl implements MemcachedCacheEntry {
@Override @Override
synchronized public byte[] toByteArray() { synchronized public byte[] toByteArray() {
final ByteArrayOutputStream bos = new ByteArrayOutputStream(); final ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutputStream oos; final ObjectOutputStream oos;
try { try {
oos = new ObjectOutputStream(bos); oos = new ObjectOutputStream(bos);
oos.writeObject(this.key); oos.writeObject(this.key);
@ -92,9 +92,9 @@ public class MemcachedCacheEntryImpl implements MemcachedCacheEntry {
@Override @Override
synchronized public void set(final byte[] bytes) { synchronized public void set(final byte[] bytes) {
final ByteArrayInputStream bis = new ByteArrayInputStream(bytes); final ByteArrayInputStream bis = new ByteArrayInputStream(bytes);
ObjectInputStream ois; final ObjectInputStream ois;
String s; final String s;
HttpCacheEntry entry; final HttpCacheEntry entry;
try { try {
ois = new ObjectInputStream(bis); ois = new ObjectInputStream(bis);
s = (String)ois.readObject(); s = (String)ois.readObject();

View File

@ -155,7 +155,7 @@ public final class HttpProxyConfigurationActivator implements BundleActivator, M
@Override @Override
public void updated(final String pid, @SuppressWarnings("rawtypes") final Dictionary config) throws ConfigurationException { public void updated(final String pid, @SuppressWarnings("rawtypes") final Dictionary config) throws ConfigurationException {
final ServiceRegistration registration = registeredConfigurations.get(pid); final ServiceRegistration registration = registeredConfigurations.get(pid);
OSGiProxyConfiguration proxyConfiguration; final OSGiProxyConfiguration proxyConfiguration;
if (registration == null) { if (registration == null) {
proxyConfiguration = new OSGiProxyConfiguration(); proxyConfiguration = new OSGiProxyConfiguration();

View File

@ -203,7 +203,7 @@ public abstract class AbstractVerifier implements X509HostnameVerifier {
final boolean doWildcard = parts.length >= 3 && parts[0].endsWith("*") && final boolean doWildcard = parts.length >= 3 && parts[0].endsWith("*") &&
(!strict || validCountryWildcard(parts)); (!strict || validCountryWildcard(parts));
if (doWildcard) { if (doWildcard) {
boolean match; final boolean match;
final String firstpart = parts[0]; final String firstpart = parts[0];
if (firstpart.length() > 1) { // e.g. server* if (firstpart.length() > 1) { // e.g. server*
final String prefix = firstpart.substring(0, firstpart.length() - 1); // e.g. server final String prefix = firstpart.substring(0, firstpart.length() - 1); // e.g. server

View File

@ -1,96 +1,96 @@
/* /*
* ==================================================================== * ====================================================================
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information * distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file * regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the * to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance * "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at * with the License. You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, * Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an * software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the * KIND, either express or implied. See the License for the
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
* ==================================================================== * ====================================================================
* *
* This software consists of voluntary contributions made by many * This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more * individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see * information on the Apache Software Foundation, please see
* <http://www.apache.org/>. * <http://www.apache.org/>.
* *
*/ */
package org.apache.http.impl.auth; package org.apache.http.impl.auth;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
/** /**
* Simple debugging utility class for CredSSP and NTLM implementations. * Simple debugging utility class for CredSSP and NTLM implementations.
*/ */
class DebugUtil class DebugUtil
{ {
public static String dump( final ByteBuffer buf ) public static String dump( final ByteBuffer buf )
{ {
final ByteBuffer dup = buf.duplicate(); final ByteBuffer dup = buf.duplicate();
final StringBuilder sb = new StringBuilder( dup.toString() ); final StringBuilder sb = new StringBuilder( dup.toString() );
sb.append( ": " ); sb.append( ": " );
while ( dup.position() < dup.limit() ) while ( dup.position() < dup.limit() )
{ {
sb.append( String.format( "%02X ", dup.get() ) ); sb.append( String.format( "%02X ", dup.get() ) );
} }
return sb.toString(); return sb.toString();
} }
public static void dump( final StringBuilder sb, final byte[] bytes ) public static void dump( final StringBuilder sb, final byte[] bytes )
{ {
if ( bytes == null ) if ( bytes == null )
{ {
sb.append( "null" ); sb.append( "null" );
return; return;
} }
for ( byte b : bytes ) for ( final byte b : bytes )
{ {
sb.append( String.format( "%02X ", b ) ); sb.append( String.format( "%02X ", b ) );
} }
} }
public static String dump( final byte[] bytes ) public static String dump( final byte[] bytes )
{ {
final StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
dump( sb, bytes ); dump( sb, bytes );
return sb.toString(); return sb.toString();
} }
public static byte[] fromHex( final String hex ) public static byte[] fromHex( final String hex )
{ {
int i = 0; int i = 0;
final byte[] bytes = new byte[200000]; final byte[] bytes = new byte[200000];
int h = 0; int h = 0;
while ( h < hex.length() ) while ( h < hex.length() )
{ {
if ( hex.charAt( h ) == ' ' ) if ( hex.charAt( h ) == ' ' )
{ {
h++; h++;
} }
final String str = hex.substring( h, h + 2 ); final String str = hex.substring( h, h + 2 );
bytes[i] = ( byte ) Integer.parseInt( str, 16 ); bytes[i] = ( byte ) Integer.parseInt( str, 16 );
i++; i++;
h = h + 2; h = h + 2;
} }
final byte[] outbytes = new byte[i]; final byte[] outbytes = new byte[i];
System.arraycopy( bytes, 0, outbytes, 0, i ); System.arraycopy( bytes, 0, outbytes, 0, i );
return outbytes; return outbytes;
} }
} }

View File

@ -821,7 +821,7 @@ final class NTLMEngineImpl implements NTLMEngine {
private Cipher initCipher() throws NTLMEngineException private Cipher initCipher() throws NTLMEngineException
{ {
Cipher cipher; final Cipher cipher;
try try
{ {
cipher = Cipher.getInstance( "RC4" ); cipher = Cipher.getInstance( "RC4" );
@ -834,7 +834,7 @@ final class NTLMEngineImpl implements NTLMEngine {
cipher.init( Cipher.DECRYPT_MODE, new SecretKeySpec( sealingKey, "RC4" ) ); cipher.init( Cipher.DECRYPT_MODE, new SecretKeySpec( sealingKey, "RC4" ) );
} }
} }
catch ( Exception e ) catch ( final Exception e )
{ {
throw new NTLMEngineException( e.getMessage(), e ); throw new NTLMEngineException( e.getMessage(), e );
} }
@ -1779,7 +1779,7 @@ final class NTLMEngineImpl implements NTLMEngine {
writeUShort( newTargetInfo, MSV_AV_CHANNEL_BINDINGS, appendLength + 8 ); writeUShort( newTargetInfo, MSV_AV_CHANNEL_BINDINGS, appendLength + 8 );
writeUShort( newTargetInfo, 16, appendLength + 10 ); writeUShort( newTargetInfo, 16, appendLength + 10 );
byte[] channelBindingsHash; final byte[] channelBindingsHash;
try try
{ {
final byte[] certBytes = peerServerCertificate.getEncoded(); final byte[] certBytes = peerServerCertificate.getEncoded();
@ -1795,11 +1795,11 @@ final class NTLMEngineImpl implements NTLMEngine {
final MessageDigest md5 = getMD5(); final MessageDigest md5 = getMD5();
channelBindingsHash = md5.digest( channelBindingStruct ); channelBindingsHash = md5.digest( channelBindingStruct );
} }
catch ( CertificateEncodingException e ) catch ( final CertificateEncodingException e )
{ {
throw new NTLMEngineException( e.getMessage(), e ); throw new NTLMEngineException( e.getMessage(), e );
} }
catch ( NoSuchAlgorithmException e ) catch ( final NoSuchAlgorithmException e )
{ {
throw new NTLMEngineException( e.getMessage(), e ); throw new NTLMEngineException( e.getMessage(), e );
} }
@ -1841,7 +1841,7 @@ final class NTLMEngineImpl implements NTLMEngine {
static MessageDigest getMD5() { static MessageDigest getMD5() {
try { try {
return MessageDigest.getInstance("MD5"); return MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException ex) { } catch (final NoSuchAlgorithmException ex) {
throw new RuntimeException("MD5 message digest doesn't seem to exist - fatal error: "+ex.getMessage(), ex); throw new RuntimeException("MD5 message digest doesn't seem to exist - fatal error: "+ex.getMessage(), ex);
} }
} }

View File

@ -1216,7 +1216,7 @@ public class HttpClientBuilder {
connectionEvictor.shutdown(); connectionEvictor.shutdown();
try { try {
connectionEvictor.awaitTermination(1L, TimeUnit.SECONDS); connectionEvictor.awaitTermination(1L, TimeUnit.SECONDS);
} catch (InterruptedException interrupted) { } catch (final InterruptedException interrupted) {
Thread.currentThread().interrupt(); Thread.currentThread().interrupt();
} }
} }

View File

@ -135,7 +135,7 @@ public class RFC2109Spec extends CookieSpecBase {
@Override @Override
public List<Header> formatCookies(final List<Cookie> cookies) { public List<Header> formatCookies(final List<Cookie> cookies) {
Args.notEmpty(cookies, "List of cookies"); Args.notEmpty(cookies, "List of cookies");
List<Cookie> cookieList; final List<Cookie> cookieList;
if (cookies.size() > 1) { if (cookies.size() > 1) {
// Create a mutable copy and sort the copy. // Create a mutable copy and sort the copy.
cookieList = new ArrayList<Cookie>(cookies); cookieList = new ArrayList<Cookie>(cookies);

View File

@ -316,7 +316,7 @@ public class TestHostnameVerifier {
@Test @Test
public void testHTTPCLIENT_1097() { public void testHTTPCLIENT_1097() {
String cns[]; final String cns[];
final String alt[] = {}; final String alt[] = {};
final X509HostnameVerifier bhv = new BrowserCompatHostnameVerifier(); final X509HostnameVerifier bhv = new BrowserCompatHostnameVerifier();
final X509HostnameVerifier shv = new StrictHostnameVerifier(); final X509HostnameVerifier shv = new StrictHostnameVerifier();

View File

@ -76,7 +76,7 @@ public class TestNTLMEngineImpl {
/* Test suite MD4 helper */ /* Test suite MD4 helper */
static void checkMD4(final String input, final String hexOutput) throws Exception { static void checkMD4(final String input, final String hexOutput) throws Exception {
NTLMEngineImpl.MD4 md4; final NTLMEngineImpl.MD4 md4;
md4 = new NTLMEngineImpl.MD4(); md4 = new NTLMEngineImpl.MD4();
md4.update(input.getBytes(Consts.ASCII)); md4.update(input.getBytes(Consts.ASCII));
final byte[] answer = md4.getOutput(); final byte[] answer = md4.getOutput();

View File

@ -89,7 +89,7 @@ public class EchoHandler
// For some reason, just putting the incoming entity into // For some reason, just putting the incoming entity into
// the response will not work. We have to buffer the message. // the response will not work. We have to buffer the message.
byte[] data; final byte[] data;
if (entity == null) { if (entity == null) {
data = new byte [0]; data = new byte [0];
} else { } else {