null
* @param backOffRate the back off rate to be used; not negative
@@ -90,24 +93,38 @@ public class ExponentialBackOffSchedulingStrategy implements SchedulingStrategy
* @see org.apache.http.impl.client.cache.CacheConfig#getAsynchronousWorkersMax()
* @see ExponentialBackOffSchedulingStrategy
*/
- public ExponentialBackOffSchedulingStrategy(final CacheConfig cacheConfig, final long backOffRate, final long initialExpiryInMillis, final long maxExpiryInMillis) {
- this(createThreadPoolFromCacheConfig(cacheConfig), backOffRate, initialExpiryInMillis, maxExpiryInMillis);
+ public ExponentialBackOffSchedulingStrategy(
+ final CacheConfig cacheConfig,
+ final long backOffRate,
+ final long initialExpiryInMillis,
+ final long maxExpiryInMillis) {
+ this(createThreadPoolFromCacheConfig(cacheConfig),
+ backOffRate,
+ initialExpiryInMillis,
+ maxExpiryInMillis);
}
- private static ScheduledThreadPoolExecutor createThreadPoolFromCacheConfig(final CacheConfig cacheConfig) {
- ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(cacheConfig.getAsynchronousWorkersMax());
+ private static ScheduledThreadPoolExecutor createThreadPoolFromCacheConfig(
+ final CacheConfig cacheConfig) {
+ final ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(
+ cacheConfig.getAsynchronousWorkersMax());
scheduledThreadPoolExecutor.setExecuteExistingDelayedTasksAfterShutdownPolicy(false);
return scheduledThreadPoolExecutor;
}
- ExponentialBackOffSchedulingStrategy(final ScheduledExecutorService executor, final long backOffRate, final long initialExpiryInMillis, final long maxExpiryInMillis) {
+ ExponentialBackOffSchedulingStrategy(
+ final ScheduledExecutorService executor,
+ final long backOffRate,
+ final long initialExpiryInMillis,
+ final long maxExpiryInMillis) {
this.executor = checkNotNull("executor", executor);
this.backOffRate = checkNotNegative("backOffRate", backOffRate);
this.initialExpiryInMillis = checkNotNegative("initialExpiryInMillis", initialExpiryInMillis);
this.maxExpiryInMillis = checkNotNegative("maxExpiryInMillis", maxExpiryInMillis);
}
- public void schedule(final AsynchronousValidationRequest revalidationRequest) {
+ public void schedule(
+ final AsynchronousValidationRequest revalidationRequest) {
checkNotNull("revalidationRequest", revalidationRequest);
final int consecutiveFailedAttempts = revalidationRequest.getConsecutiveFailedAttempts();
final long delayInMillis = calculateDelayInMillis(consecutiveFailedAttempts);
@@ -132,7 +149,8 @@ public class ExponentialBackOffSchedulingStrategy implements SchedulingStrategy
protected long calculateDelayInMillis(final int consecutiveFailedAttempts) {
if (consecutiveFailedAttempts > 0) {
- final long delayInSeconds = (long) (initialExpiryInMillis * Math.pow(backOffRate, consecutiveFailedAttempts - 1));
+ final long delayInSeconds = (long) (initialExpiryInMillis *
+ Math.pow(backOffRate, consecutiveFailedAttempts - 1));
return Math.min(delayInSeconds, maxExpiryInMillis);
}
else {
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java
index 809bf1452..98137aea1 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/FailureCacheValue.java
@@ -40,7 +40,7 @@ public class FailureCacheValue {
private final String key;
private final int errorCount;
- public FailureCacheValue(String key, int errorCount) {
+ public FailureCacheValue(final String key, final int errorCount) {
this.creationTimeInNanos = System.nanoTime();
this.key = key;
this.errorCount = errorCount;
@@ -61,6 +61,7 @@ public class FailureCacheValue {
@Override
public String toString() {
- return "[entry creationTimeInNanos=" + creationTimeInNanos + "; key=" + key + "; errorCount=" + errorCount + ']';
+ return "[entry creationTimeInNanos=" + creationTimeInNanos + "; " +
+ "key=" + key + "; errorCount=" + errorCount + ']';
}
}
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java
index f75bc2996..8b0ce5223 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/HeapResourceFactory.java
@@ -76,7 +76,7 @@ public class HeapResourceFactory implements ResourceFactory {
return createResource(body);
}
- Resource createResource(byte[] buf) {
+ Resource createResource(final byte[] buf) {
return new HeapResource(buf);
}
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java
index 44dd99314..315e397ce 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/ManagedHttpCacheStorage.java
@@ -28,7 +28,6 @@ package org.apache.http.impl.client.cache;
import java.io.Closeable;
import java.io.IOException;
-import java.lang.ref.PhantomReference;
import java.lang.ref.ReferenceQueue;
import java.util.HashSet;
import java.util.Set;
@@ -42,12 +41,13 @@ import org.apache.http.util.Args;
/**
* {@link HttpCacheStorage} implementation capable of deallocating resources associated with
- * the cache entries. This cache keeps track of cache entries using {@link PhantomReference}
- * and maintains a collection of all resources that are no longer in use. The cache, however,
- * does not automatically deallocates associated resources by invoking {@link Resource#dispose()}
- * method. The consumer MUST periodically call {@link #cleanResources()} method to trigger
- * resource deallocation. The cache can be permanently shut down using {@link #shutdown()}
- * method. All resources associated with the entries used by the cache will be deallocated.
+ * the cache entries. This cache keeps track of cache entries using
+ * {@link java.lang.ref.PhantomReference} and maintains a collection of all resources that
+ * are no longer in use. The cache, however, does not automatically deallocates associated
+ * resources by invoking {@link Resource#dispose()} method. The consumer MUST periodically
+ * call {@link #cleanResources()} method to trigger resource deallocation. The cache can be
+ * permanently shut down using {@link #shutdown()} method. All resources associated with
+ * the entries used by the cache will be deallocated.
*
* This {@link HttpCacheStorage} implementation is intended for use with {@link FileResource}
* and similar.
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 544420395..4e5aadd77 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
@@ -78,7 +78,7 @@ class ResponseCachingPolicy {
public ResponseCachingPolicy(final long maxObjectSizeBytes,
final boolean sharedCache,
final boolean neverCache1_0ResponsesWithQueryString,
- boolean allow303Caching) {
+ final boolean allow303Caching) {
this.maxObjectSizeBytes = maxObjectSizeBytes;
this.sharedCache = sharedCache;
this.neverCache1_0ResponsesWithQueryString = neverCache1_0ResponsesWithQueryString;
diff --git a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/KeyHashingScheme.java b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/KeyHashingScheme.java
index 2a99c103a..12d34cbb4 100644
--- a/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/KeyHashingScheme.java
+++ b/httpclient-cache/src/main/java/org/apache/http/impl/client/cache/memcached/KeyHashingScheme.java
@@ -51,14 +51,13 @@
*
*/package org.apache.http.impl.client.cache.memcached;
-import org.apache.http.client.cache.HttpCacheStorage;
-
/**
- * Since the {@link HttpCacheStorage} interface expects to use variant-annotated
- * URLs for its storage keys, but Memcached has a maximum key size, we need to
- * support mapping storage keys to cache keys. Clients can implement this
- * interface to change the way the mapping is done (for example, to add a prefix
- * to all cache keys to provide a form of memcached namespacing).
+ * Since the {@link org.apache.http.client.cache.HttpCacheStorage} interface
+ * expects to use variant-annotated URLs for its storage keys, but Memcached
+ * has a maximum key size, we need to support mapping storage keys to cache
+ * keys. Clients can implement this interface to change the way the mapping
+ * is done (for example, to add a prefix to all cache keys to provide a form
+ * of memcached namespacing).
*/
public interface KeyHashingScheme {
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClientBuilder.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClientBuilder.java
index 1ec666835..c098c9884 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClientBuilder.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestCachingHttpClientBuilder.java
@@ -32,7 +32,9 @@ public class TestCachingHttpClientBuilder {
@Test
public void testAsynchronousWorkersMax0() throws Exception {
- CacheConfig cacheConfig = CacheConfig.custom().setAsynchronousWorkersMax(0).build();
+ final CacheConfig cacheConfig = CacheConfig.custom()
+ .setAsynchronousWorkersMax(0)
+ .build();
// Asynchronous validation should be disabled but we should not get an
// Exception
CachingHttpClientBuilder.create().setCacheConfig(cacheConfig).build();
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestDefaultFailureCache.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestDefaultFailureCache.java
index c38329500..75cc40d82 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestDefaultFailureCache.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestDefaultFailureCache.java
@@ -41,7 +41,7 @@ public class TestDefaultFailureCache
failureCache.increaseErrorCount(IDENTIFIER);
failureCache.resetErrorCount(IDENTIFIER);
- int errorCount = failureCache.getErrorCount(IDENTIFIER);
+ final int errorCount = failureCache.getErrorCount(IDENTIFIER);
Assert.assertEquals(0, errorCount);
}
@@ -51,7 +51,7 @@ public class TestDefaultFailureCache
failureCache.increaseErrorCount(IDENTIFIER);
failureCache.increaseErrorCount(IDENTIFIER);
- int errorCount = failureCache.getErrorCount(IDENTIFIER);
+ final int errorCount = failureCache.getErrorCount(IDENTIFIER);
Assert.assertEquals(3, errorCount);
}
@@ -63,7 +63,7 @@ public class TestDefaultFailureCache
failureCache.increaseErrorCount("c");
failureCache.increaseErrorCount("d");
- int errorCount = failureCache.getErrorCount("a");
+ final int errorCount = failureCache.getErrorCount("a");
Assert.assertEquals(0, errorCount);
}
}
diff --git a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestExponentialBackingOffSchedulingStrategy.java b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestExponentialBackingOffSchedulingStrategy.java
index f0718dd5b..7d5c36687 100644
--- a/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestExponentialBackingOffSchedulingStrategy.java
+++ b/httpclient-cache/src/test/java/org/apache/http/impl/client/cache/TestExponentialBackingOffSchedulingStrategy.java
@@ -58,7 +58,7 @@ public class TestExponentialBackingOffSchedulingStrategy {
@Test
public void testScheduleWithoutPreviousError() {
- AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(0));
+ final AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(0));
expectRequestScheduledWithoutDelay(request);
@@ -69,7 +69,7 @@ public class TestExponentialBackingOffSchedulingStrategy {
@Test
public void testScheduleWithOneFailedAttempt() {
- AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(1));
+ final AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(1));
expectRequestScheduledWithDelay(request, TimeUnit.SECONDS.toMillis(6));
@@ -80,7 +80,7 @@ public class TestExponentialBackingOffSchedulingStrategy {
@Test
public void testScheduleWithTwoFailedAttempts() {
- AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(2));
+ final AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(2));
expectRequestScheduledWithDelay(request, TimeUnit.SECONDS.toMillis(60));
@@ -91,7 +91,7 @@ public class TestExponentialBackingOffSchedulingStrategy {
@Test
public void testScheduleWithThreeFailedAttempts() {
- AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(3));
+ final AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(3));
expectRequestScheduledWithDelay(request, TimeUnit.SECONDS.toMillis(600));
@@ -102,7 +102,7 @@ public class TestExponentialBackingOffSchedulingStrategy {
@Test
public void testScheduleWithFourFailedAttempts() {
- AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(4));
+ final AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(4));
expectRequestScheduledWithDelay(request, TimeUnit.SECONDS.toMillis(6000));
@@ -113,7 +113,7 @@ public class TestExponentialBackingOffSchedulingStrategy {
@Test
public void testScheduleWithFiveFailedAttempts() {
- AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(5));
+ final AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(5));
expectRequestScheduledWithDelay(request, TimeUnit.SECONDS.toMillis(60000));
@@ -124,7 +124,7 @@ public class TestExponentialBackingOffSchedulingStrategy {
@Test
public void testScheduleWithSixFailedAttempts() {
- AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(6));
+ final AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(6));
expectRequestScheduledWithDelay(request, TimeUnit.SECONDS.toMillis(86400));
@@ -135,7 +135,7 @@ public class TestExponentialBackingOffSchedulingStrategy {
@Test
public void testScheduleWithMaxNumberOfFailedAttempts() {
- AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(Integer.MAX_VALUE));
+ final AsynchronousValidationRequest request = createAsynchronousValidationRequest(withErrorCount(Integer.MAX_VALUE));
expectRequestScheduledWithDelay(request, TimeUnit.SECONDS.toMillis(86400));
diff --git a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/PropertiesUtils.java b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/PropertiesUtils.java
index 7d69b01b3..c7690b129 100644
--- a/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/PropertiesUtils.java
+++ b/httpclient-osgi/src/main/java/org/apache/http/osgi/impl/PropertiesUtils.java
@@ -49,32 +49,32 @@ final class PropertiesUtils {
register(new DoublePropertyConverter(), double.class, Double.class);
}
- private static void register(PropertyConverter> converter, Class>...targetTypes) {
- for (Class> targetType : targetTypes) {
+ private static void register(final PropertyConverter> converter, final Class>...targetTypes) {
+ for (final Class> targetType : targetTypes) {
CONVERTERS_REGISTRY.put(targetType, converter);
}
}
- public static * This parameter expects a value of type {@link java.util.Collection}. The * collection is expected to contain {@link String} instances representing * a name of an authentication scheme as returned by - * {@link AuthScheme#getSchemeName()}. + * {@link org.apache.http.auth.AuthScheme#getSchemeName()}. */ public static final String TARGET_AUTH_PREF = "http.auth.target-scheme-pref"; /** - * Defines the order of preference for supported {@link AuthScheme}s when - * authenticating with the proxy host. + * Defines the order of preference for supported + * {@link org.apache.http.auth.AuthScheme}s when authenticating with the + * proxy host. *
* This parameter expects a value of type {@link java.util.Collection}. The
* collection is expected to contain {@link String} instances representing
* a name of an authentication scheme as returned by
- * {@link AuthScheme#getSchemeName()}.
+ * {@link org.apache.http.auth.AuthScheme#getSchemeName()}.
*/
public static final String PROXY_AUTH_PREF = "http.auth.proxy-scheme-pref";
diff --git a/httpclient/src/main/java/org/apache/http/auth/params/AuthParamBean.java b/httpclient/src/main/java/org/apache/http/auth/params/AuthParamBean.java
index 57a6c12a4..4d4476308 100644
--- a/httpclient/src/main/java/org/apache/http/auth/params/AuthParamBean.java
+++ b/httpclient/src/main/java/org/apache/http/auth/params/AuthParamBean.java
@@ -27,8 +27,6 @@
package org.apache.http.auth.params;
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.client.config.RequestConfig;
import org.apache.http.params.HttpAbstractParamBean;
import org.apache.http.params.HttpParams;
@@ -39,8 +37,9 @@ import org.apache.http.params.HttpParams;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig} and constructor parameters of
- * {@link AuthSchemeProvider}s.
+ * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig}
+ * and constructor parameters of
+ * {@link org.apache.http.auth.AuthSchemeProvider}s.
*/
@Deprecated
public class AuthParamBean extends HttpAbstractParamBean {
diff --git a/httpclient/src/main/java/org/apache/http/auth/params/AuthParams.java b/httpclient/src/main/java/org/apache/http/auth/params/AuthParams.java
index 58bdf1651..a7de77000 100644
--- a/httpclient/src/main/java/org/apache/http/auth/params/AuthParams.java
+++ b/httpclient/src/main/java/org/apache/http/auth/params/AuthParams.java
@@ -28,8 +28,6 @@
package org.apache.http.auth.params;
import org.apache.http.annotation.Immutable;
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.client.config.RequestConfig;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HTTP;
import org.apache.http.util.Args;
@@ -40,8 +38,9 @@ import org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig} and constructor parameters of
- * {@link AuthSchemeProvider}s.
+ * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig}
+ * and constructor parameters of
+ * {@link org.apache.http.auth.AuthSchemeProvider}s.
*/
@Immutable
@Deprecated
diff --git a/httpclient/src/main/java/org/apache/http/client/HttpClient.java b/httpclient/src/main/java/org/apache/http/client/HttpClient.java
index 3ace3eeef..a7ce67140 100644
--- a/httpclient/src/main/java/org/apache/http/client/HttpClient.java
+++ b/httpclient/src/main/java/org/apache/http/client/HttpClient.java
@@ -27,18 +27,16 @@
package org.apache.http.client;
-import java.io.IOException;
-
import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
-import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;
+import java.io.IOException;
+
/**
* This interface represents only the most basic contract for HTTP request
* execution. It imposes no restrictions or particular details on the request
@@ -115,7 +113,8 @@ public interface HttpClient {
*
* @return the default parameters
*
- * @deprecated (4.3) use {@link RequestConfig}.
+ * @deprecated (4.3) use
+ * {@link org.apache.http.client.config.RequestConfig}.
*/
@Deprecated
HttpParams getParams();
@@ -125,7 +124,8 @@ public interface HttpClient {
*
* @return the connection manager
*
- * @deprecated (4.3) use {@link HttpClientBuilder}.
+ * @deprecated (4.3) use
+ * {@link org.apache.http.impl.client.HttpClientBuilder}.
*/
@Deprecated
ClientConnectionManager getConnectionManager();
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java
index bd78adc77..4089d002c 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java
@@ -31,16 +31,18 @@ import java.io.InputStream;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
-import org.apache.http.entity.HttpEntityWrapper;
/**
- * {@link HttpEntityWrapper} responsible for handling deflate Content Coded responses. In RFC2616
- * terms, deflate
means a zlib
stream as defined in RFC1950. Some server
- * implementations have misinterpreted RFC2616 to mean that a deflate
stream as
- * defined in RFC1951 should be used (or maybe they did that since that's how IE behaves?). It's
- * confusing that deflate
in HTTP 1.1 means zlib
streams rather than
- * deflate
streams. We handle both types in here, since that's what is seen on the
- * internet. Moral - prefer gzip
!
+ * {@link org.apache.http.entity.HttpEntityWrapper} responsible for handling
+ * deflate Content Coded responses. In RFC2616 terms, deflate
+ * means a zlib
stream as defined in RFC1950. Some server
+ * implementations have misinterpreted RFC2616 to mean that a
+ * deflate
stream as defined in RFC1951 should be used
+ * (or maybe they did that since that's how IE behaves?). It's confusing
+ * that deflate
in HTTP 1.1 means zlib
streams
+ * rather than deflate
streams. We handle both types in here,
+ * since that's what is seen on the internet. Moral - prefer
+ * gzip
!
*
* @see GzipDecompressingEntity
*
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/DeflateInputStream.java b/httpclient/src/main/java/org/apache/http/client/entity/DeflateInputStream.java
index 310ca8cf4..dfd8f4be4 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/DeflateInputStream.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/DeflateInputStream.java
@@ -138,7 +138,7 @@ public class DeflateInputStream extends InputStream
/** Read lots of bytes.
*/
@Override
- public int read(byte[] b)
+ public int read(final byte[] b)
throws IOException
{
return sourceStream.read(b);
@@ -147,7 +147,7 @@ public class DeflateInputStream extends InputStream
/** Read lots of specific bytes.
*/
@Override
- public int read(byte[] b, int off, int len)
+ public int read(final byte[] b, final int off, final int len)
throws IOException
{
return sourceStream.read(b,off,len);
@@ -156,7 +156,7 @@ public class DeflateInputStream extends InputStream
/** Skip
*/
@Override
- public long skip(long n)
+ public long skip(final long n)
throws IOException
{
return sourceStream.skip(n);
@@ -174,7 +174,7 @@ public class DeflateInputStream extends InputStream
/** Mark.
*/
@Override
- public void mark(int readLimit)
+ public void mark(final int readLimit)
{
sourceStream.mark(readLimit);
}
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java b/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java
index 4b3b5f267..9544829be 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/EntityBuilder.java
@@ -184,7 +184,7 @@ public class EntityBuilder {
}
public HttpEntity build() {
- AbstractHttpEntity e;
+ final AbstractHttpEntity e;
if (this.text != null) {
e = new StringEntity(this.text, getContentOrDefault(ContentType.DEFAULT_TEXT));
} else if (this.binary != null) {
diff --git a/httpclient/src/main/java/org/apache/http/client/entity/GzipDecompressingEntity.java b/httpclient/src/main/java/org/apache/http/client/entity/GzipDecompressingEntity.java
index ddd7c9416..a0198efd6 100644
--- a/httpclient/src/main/java/org/apache/http/client/entity/GzipDecompressingEntity.java
+++ b/httpclient/src/main/java/org/apache/http/client/entity/GzipDecompressingEntity.java
@@ -32,10 +32,10 @@ import java.util.zip.GZIPInputStream;
import org.apache.http.Header;
import org.apache.http.HttpEntity;
-import org.apache.http.entity.HttpEntityWrapper;
/**
- * {@link HttpEntityWrapper} for handling gzip Content Coded responses.
+ * {@link org.apache.http.entity.HttpEntityWrapper} for handling gzip
+ * Content Coded responses.
*
* @since 4.1
*/
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java b/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java
index ca7cc7c7d..4b066ed87 100644
--- a/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java
+++ b/httpclient/src/main/java/org/apache/http/client/methods/AbortableHttpRequest.java
@@ -27,13 +27,11 @@
package org.apache.http.client.methods;
-import java.io.IOException;
-
-import org.apache.http.client.HttpClient;
-import org.apache.http.conn.ClientConnectionManager;
import org.apache.http.conn.ClientConnectionRequest;
import org.apache.http.conn.ConnectionReleaseTrigger;
-import org.apache.http.conn.ManagedClientConnection;
+
+import java.io.IOException;
+
/**
* Interface representing an HTTP request that can be aborted by shutting
@@ -47,18 +45,19 @@ import org.apache.http.conn.ManagedClientConnection;
public interface AbortableHttpRequest {
/**
- * Sets the {@link ClientConnectionRequest} callback that can be
- * used to abort a long-lived request for a connection.
+ * Sets the {@link org.apache.http.conn.ClientConnectionRequest}
+ * callback that can be used to abort a long-lived request for a connection.
* If the request is already aborted, throws an {@link IOException}.
*
- * @see ClientConnectionManager
+ * @see org.apache.http.conn.ClientConnectionManager
*/
void setConnectionRequest(ClientConnectionRequest connRequest) throws IOException;
/**
* Sets the {@link ConnectionReleaseTrigger} callback that can
* be used to abort an active connection.
- * Typically, this will be the {@link ManagedClientConnection} itself.
+ * Typically, this will be the
+ * {@link org.apache.http.conn.ManagedClientConnection} itself.
* If the request is already aborted, throws an {@link IOException}.
*/
void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException;
@@ -69,12 +68,12 @@ public interface AbortableHttpRequest {
* the next execution. Aborting this request will cause all subsequent
* executions with this request to fail.
*
- * @see HttpClient#execute(HttpUriRequest)
- * @see HttpClient#execute(org.apache.http.HttpHost,
+ * @see org.apache.http.client.HttpClient#execute(HttpUriRequest)
+ * @see org.apache.http.client.HttpClient#execute(org.apache.http.HttpHost,
* org.apache.http.HttpRequest)
- * @see HttpClient#execute(HttpUriRequest,
+ * @see org.apache.http.client.HttpClient#execute(HttpUriRequest,
* org.apache.http.protocol.HttpContext)
- * @see HttpClient#execute(org.apache.http.HttpHost,
+ * @see org.apache.http.client.HttpClient#execute(org.apache.http.HttpHost,
* org.apache.http.HttpRequest, org.apache.http.protocol.HttpContext)
*/
void abort();
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
index 3bce5ad61..771185f50 100644
--- a/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
+++ b/httpclient/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
@@ -36,7 +36,6 @@ import org.apache.http.HttpRequest;
import org.apache.http.ProtocolVersion;
import org.apache.http.RequestLine;
import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.client.config.RequestConfig;
import org.apache.http.message.AbstractHttpMessage;
import org.apache.http.message.BasicRequestLine;
import org.apache.http.params.HttpParams;
@@ -157,7 +156,8 @@ public class HttpRequestWrapper extends AbstractHttpMessage implements HttpUriRe
}
/**
- * @deprecated (4.3) use {@link RequestConfig}.
+ * @deprecated (4.3) use
+ * {@link org.apache.http.client.config.RequestConfig}.
*/
@Override
@Deprecated
diff --git a/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java b/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java
index d77b0a990..31ec24be1 100644
--- a/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java
+++ b/httpclient/src/main/java/org/apache/http/client/methods/RequestBuilder.java
@@ -277,7 +277,7 @@ public class RequestBuilder {
}
public HttpUriRequest build() {
- HttpRequestBase result;
+ final HttpRequestBase result;
URI uri = this.uri != null ? this.uri : URI.create("/");
HttpEntity entity = this.entity;
if (parameters != null && !parameters.isEmpty()) {
diff --git a/httpclient/src/main/java/org/apache/http/client/params/AllClientPNames.java b/httpclient/src/main/java/org/apache/http/client/params/AllClientPNames.java
index 50ab2346a..d11fe0955 100644
--- a/httpclient/src/main/java/org/apache/http/client/params/AllClientPNames.java
+++ b/httpclient/src/main/java/org/apache/http/client/params/AllClientPNames.java
@@ -27,7 +27,6 @@
package org.apache.http.client.params;
import org.apache.http.auth.params.AuthPNames;
-import org.apache.http.client.config.RequestConfig;
import org.apache.http.conn.params.ConnConnectionPNames;
import org.apache.http.conn.params.ConnManagerPNames;
import org.apache.http.conn.params.ConnRoutePNames;
@@ -48,7 +47,10 @@ import org.apache.http.params.CoreProtocolPNames;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}
+ * @deprecated (4.3) use
+ * {@link org.apache.http.client.config.RequestConfig},
+ * {@link org.apache.http.config.ConnectionConfig},
+ * {@link org.apache.http.config.SocketConfig}
*/
@Deprecated
public interface AllClientPNames extends
diff --git a/httpclient/src/main/java/org/apache/http/client/params/AuthPolicy.java b/httpclient/src/main/java/org/apache/http/client/params/AuthPolicy.java
index d4ddec233..c04a6c1ed 100644
--- a/httpclient/src/main/java/org/apache/http/client/params/AuthPolicy.java
+++ b/httpclient/src/main/java/org/apache/http/client/params/AuthPolicy.java
@@ -28,14 +28,13 @@
package org.apache.http.client.params;
import org.apache.http.annotation.Immutable;
-import org.apache.http.client.config.AuthSchemes;
/**
* Standard authentication schemes supported by HttpClient.
*
* @since 4.0
*
- * @deprecated (4.3) use {@link AuthSchemes}
+ * @deprecated (4.3) use {@link org.apache.http.client.config.AuthSchemes}.
*/
@Deprecated
@Immutable
diff --git a/httpclient/src/main/java/org/apache/http/client/params/ClientPNames.java b/httpclient/src/main/java/org/apache/http/client/params/ClientPNames.java
index aebe3bd54..1249e2f73 100644
--- a/httpclient/src/main/java/org/apache/http/client/params/ClientPNames.java
+++ b/httpclient/src/main/java/org/apache/http/client/params/ClientPNames.java
@@ -26,14 +26,12 @@
*/
package org.apache.http.client.params;
-import org.apache.http.client.config.RequestConfig;
-
/**
* Parameter names for HTTP client parameters.
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}
+ * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig}.
*/
@Deprecated
public interface ClientPNames {
diff --git a/httpclient/src/main/java/org/apache/http/client/params/ClientParamBean.java b/httpclient/src/main/java/org/apache/http/client/params/ClientParamBean.java
index 8f36a8dab..99ba8510e 100644
--- a/httpclient/src/main/java/org/apache/http/client/params/ClientParamBean.java
+++ b/httpclient/src/main/java/org/apache/http/client/params/ClientParamBean.java
@@ -32,7 +32,6 @@ import java.util.Collection;
import org.apache.http.Header;
import org.apache.http.HttpHost;
import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.client.config.RequestConfig;
import org.apache.http.params.HttpAbstractParamBean;
import org.apache.http.params.HttpParams;
@@ -43,7 +42,7 @@ import org.apache.http.params.HttpParams;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}
+ * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig}.
*/
@Deprecated
@NotThreadSafe
diff --git a/httpclient/src/main/java/org/apache/http/client/params/CookiePolicy.java b/httpclient/src/main/java/org/apache/http/client/params/CookiePolicy.java
index 188d17918..e12ab426d 100644
--- a/httpclient/src/main/java/org/apache/http/client/params/CookiePolicy.java
+++ b/httpclient/src/main/java/org/apache/http/client/params/CookiePolicy.java
@@ -28,14 +28,13 @@
package org.apache.http.client.params;
import org.apache.http.annotation.Immutable;
-import org.apache.http.client.config.CookieSpecs;
/**
* Standard cookie specifications supported by HttpClient.
*
* @since 4.0
*
- * @deprecated (4.3) use {@link CookieSpecs}
+ * @deprecated (4.3) use {@link org.apache.http.client.config.CookieSpecs}.
*/
@Deprecated
@Immutable
diff --git a/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java b/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java
index ff5a5464e..c27cb7f93 100644
--- a/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java
+++ b/httpclient/src/main/java/org/apache/http/client/params/HttpClientParams.java
@@ -27,7 +27,6 @@
package org.apache.http.client.params;
import org.apache.http.annotation.Immutable;
-import org.apache.http.client.config.RequestConfig;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.apache.http.util.Args;
@@ -37,7 +36,7 @@ import org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link RequestConfig}
+ * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig}
*/
@Deprecated
@Immutable
diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/ClientContext.java b/httpclient/src/main/java/org/apache/http/client/protocol/ClientContext.java
index d538eda63..4794f612a 100644
--- a/httpclient/src/main/java/org/apache/http/client/protocol/ClientContext.java
+++ b/httpclient/src/main/java/org/apache/http/client/protocol/ClientContext.java
@@ -27,15 +27,13 @@
package org.apache.http.client.protocol;
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.cookie.CookieSpecProvider;
-
/**
* {@link org.apache.http.protocol.HttpContext} attribute names for
* client side HTTP protocol processing.
*
* @since 4.0
+ *
+ * @deprecated (4.3) use {@link HttpClientContext}.
*/
@Deprecated
public interface ClientContext {
@@ -51,15 +49,13 @@ public interface ClientContext {
/**
* Attribute name of a {@link org.apache.http.conn.scheme.Scheme}
* object that represents the actual protocol scheme registry.
- *
- * @deprecated (4.3) do not use
*/
@Deprecated
public static final String SCHEME_REGISTRY = "http.scheme-registry";
/**
* Attribute name of a {@link org.apache.http.config.Lookup} object that represents
- * the actual {@link CookieSpecProvider} registry.
+ * the actual {@link org.apache.http.cookie.CookieSpecRegistry} registry.
*/
public static final String COOKIESPEC_REGISTRY = "http.cookiespec-registry";
@@ -119,16 +115,10 @@ public interface ClientContext {
/**
* Attribute name of a {@link org.apache.http.config.Lookup} object that represents
- * the actual {@link AuthSchemeProvider} registry.
+ * the actual {@link org.apache.http.auth.AuthSchemeRegistry} registry.
*/
public static final String AUTHSCHEME_REGISTRY = "http.authscheme-registry";
- /**
- * Attribute name of a {@link org.apache.http.config.Lookup} object that represents
- * the actual {@link ConnectionSocketFactory} registry.
- *
- * @since 4.3
- */
public static final String SOCKET_FACTORY_REGISTRY = "http.socket-factory-registry";
/**
diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
index d6ab066da..710fd5722 100644
--- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
+++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestAddCookies.java
@@ -45,6 +45,7 @@ import org.apache.http.annotation.Immutable;
import org.apache.http.client.CookieStore;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.HttpUriRequest;
import org.apache.http.config.Lookup;
import org.apache.http.conn.routing.RouteInfo;
import org.apache.http.cookie.Cookie;
@@ -122,9 +123,13 @@ public class RequestAddCookies implements HttpRequestInterceptor {
}
URI requestURI = null;
- try {
- requestURI = new URI(request.getRequestLine().getUri());
- } catch (final URISyntaxException ignore) {
+ if (request instanceof HttpUriRequest) {
+ requestURI = ((HttpUriRequest) request).getURI();
+ } else {
+ try {
+ requestURI = new URI(request.getRequestLine().getUri());
+ } catch (final URISyntaxException ignore) {
+ }
}
final String path = requestURI != null ? requestURI.getPath() : null;
final String hostName = targetHost.getHostName();
diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestProxyAuthentication.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestProxyAuthentication.java
index 807b32ecb..686d86983 100644
--- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestProxyAuthentication.java
+++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestProxyAuthentication.java
@@ -36,7 +36,6 @@ import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthState;
import org.apache.http.conn.HttpRoutedConnection;
import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.impl.client.HttpAuthenticator;
import org.apache.http.protocol.ExecutionContext;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;
@@ -47,7 +46,7 @@ import org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link HttpAuthenticator}.
+ * @deprecated (4.3) use {@link org.apache.http.impl.auth.HttpAuthenticator}.
*/
@Deprecated
@Immutable
diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/RequestTargetAuthentication.java b/httpclient/src/main/java/org/apache/http/client/protocol/RequestTargetAuthentication.java
index d8b57d945..30d1a89ea 100644
--- a/httpclient/src/main/java/org/apache/http/client/protocol/RequestTargetAuthentication.java
+++ b/httpclient/src/main/java/org/apache/http/client/protocol/RequestTargetAuthentication.java
@@ -34,7 +34,6 @@ import org.apache.http.HttpRequest;
import org.apache.http.annotation.Immutable;
import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthState;
-import org.apache.http.impl.client.HttpAuthenticator;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;
@@ -44,7 +43,7 @@ import org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link HttpAuthenticator}.
+ * @deprecated (4.3) use {@link org.apache.http.impl.auth.HttpAuthenticator}.
*/
@Deprecated
@Immutable
diff --git a/httpclient/src/main/java/org/apache/http/client/protocol/ResponseAuthCache.java b/httpclient/src/main/java/org/apache/http/client/protocol/ResponseAuthCache.java
index 4199f0e97..71b1a606f 100644
--- a/httpclient/src/main/java/org/apache/http/client/protocol/ResponseAuthCache.java
+++ b/httpclient/src/main/java/org/apache/http/client/protocol/ResponseAuthCache.java
@@ -39,7 +39,6 @@ import org.apache.http.annotation.Immutable;
import org.apache.http.auth.AuthScheme;
import org.apache.http.auth.AuthState;
import org.apache.http.client.AuthCache;
-import org.apache.http.client.AuthenticationStrategy;
import org.apache.http.client.params.AuthPolicy;
import org.apache.http.conn.scheme.Scheme;
import org.apache.http.conn.scheme.SchemeRegistry;
@@ -56,7 +55,7 @@ import org.apache.http.util.Args;
*
* @since 4.1
*
- * @deprecated (4.2) use {@link AuthenticationStrategy}
+ * @deprecated (4.2) use {@link org.apache.http.client.AuthenticationStrategy}
*/
@Immutable
@Deprecated
diff --git a/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java
index 896bcfd67..89720f62f 100644
--- a/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/CloneUtils.java
@@ -49,7 +49,7 @@ public class CloneUtils {
}
if (obj instanceof Cloneable) {
final Class> clazz = obj.getClass ();
- Method m;
+ final Method m;
try {
m = clazz.getMethod("clone", (Class[]) null);
} catch (final NoSuchMethodException ex) {
diff --git a/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java
index 9c9a6ef9b..d53563375 100644
--- a/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/DateUtils.java
@@ -28,7 +28,6 @@
package org.apache.http.client.utils;
import java.lang.ref.SoftReference;
-import java.text.DateFormat;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Calendar;
@@ -125,31 +124,24 @@ public final class DateUtils {
* @return the parsed date or null if input could not be parsed
*/
public static Date parseDate(
- String dateValue,
- String[] dateFormats,
- Date startDate
- ) {
+ final String dateValue,
+ final String[] dateFormats,
+ final Date startDate) {
Args.notNull(dateValue, "Date value");
- if (dateFormats == null) {
- dateFormats = DEFAULT_PATTERNS;
- }
- if (startDate == null) {
- startDate = DEFAULT_TWO_DIGIT_YEAR_START;
- }
+ final String[] localDateFormats = dateFormats != null ? dateFormats : DEFAULT_PATTERNS;
+ final Date localStartDate = startDate != null ? startDate : DEFAULT_TWO_DIGIT_YEAR_START;
+ String v = dateValue;
// trim single quotes around date if present
// see issue #5279
- if (dateValue.length() > 1
- && dateValue.startsWith("'")
- && dateValue.endsWith("'")
- ) {
- dateValue = dateValue.substring (1, dateValue.length() - 1);
+ if (v.length() > 1 && v.startsWith("'") && v.endsWith("'")) {
+ v = v.substring (1, v.length() - 1);
}
- for (final String dateFormat : dateFormats) {
+ for (final String dateFormat : localDateFormats) {
final SimpleDateFormat dateParser = DateFormatHolder.formatFor(dateFormat);
- dateParser.set2DigitYearStart(startDate);
+ dateParser.set2DigitYearStart(localStartDate);
final ParsePosition pos = new ParsePosition(0);
- final Date result = dateParser.parse(dateValue, pos);
+ final Date result = dateParser.parse(v, pos);
if (pos.getIndex() != 0) {
return result;
}
@@ -190,7 +182,7 @@ public final class DateUtils {
}
/**
- * Clears thread-local variable containing {@link DateFormat} cache.
+ * Clears thread-local variable containing {@link java.text.DateFormat} cache.
*
* @since 4.3
*/
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 1f5faa316..293d9b065 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
@@ -47,19 +47,20 @@ public class Rfc3492Idn implements Idn {
private static final char delimiter = '-';
private static final String ACE_PREFIX = "xn--";
- private int adapt(int delta, final int numpoints, final boolean firsttime) {
+ private int adapt(final int delta, final int numpoints, final boolean firsttime) {
+ int d = delta;
if (firsttime) {
- delta = delta / damp;
+ d = d / damp;
} else {
- delta = delta / 2;
+ d = d / 2;
}
- delta = delta + (delta / numpoints);
+ d = d + (d / numpoints);
int k = 0;
- while (delta > ((base - tmin) * tmax) / 2) {
- delta = delta / (base - tmin);
+ while (d > ((base - tmin) * tmax) / 2) {
+ d = d / (base - tmin);
k = k + base;
}
- return k + (((base - tmin + 1) * delta) / (delta + skew));
+ return k + (((base - tmin + 1) * d) / (d + skew));
}
private int digit(final char c) {
@@ -91,7 +92,8 @@ public class Rfc3492Idn implements Idn {
return unicode.toString();
}
- protected String decode(String input) {
+ protected String decode(final String s) {
+ String input = s;
int n = initial_n;
int i = 0;
int bias = initial_bias;
@@ -113,7 +115,7 @@ public class Rfc3492Idn implements Idn {
input = input.substring(1);
final int digit = digit(c);
i = i + digit * w; // FIXME fail on overflow
- int t;
+ final int t;
if (k <= bias + tmin) {
t = tmin;
} else if (k >= bias + tmax) {
diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java b/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
index 7982ad692..efc78a211 100644
--- a/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/URIBuilder.java
@@ -470,20 +470,21 @@ public class URIBuilder {
return buildString();
}
- private static String normalizePath(String path) {
- if (path == null) {
+ private static String normalizePath(final String path) {
+ String s = path;
+ if (s == null) {
return null;
}
int n = 0;
- for (; n < path.length(); n++) {
- if (path.charAt(n) != '/') {
+ for (; n < s.length(); n++) {
+ if (s.charAt(n) != '/') {
break;
}
}
if (n > 1) {
- path = path.substring(n - 1);
+ s = s.substring(n - 1);
}
- return path;
+ return s;
}
}
diff --git a/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java b/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
index 355ad30d2..2a852b812 100644
--- a/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
+++ b/httpclient/src/main/java/org/apache/http/client/utils/URIUtils.java
@@ -34,7 +34,6 @@ import java.util.Stack;
import org.apache.http.HttpHost;
import org.apache.http.annotation.Immutable;
-import org.apache.http.client.URICollection;
import org.apache.http.util.Args;
import org.apache.http.util.TextUtils;
@@ -216,18 +215,19 @@ public class URIUtils {
* @param reference the URI reference
* @return the resulting URI
*/
- public static URI resolve(final URI baseURI, URI reference){
+ public static URI resolve(final URI baseURI, final URI reference){
Args.notNull(baseURI, "Base URI");
Args.notNull(reference, "Reference URI");
- final String s = reference.toString();
+ URI ref = reference;
+ final String s = ref.toString();
if (s.startsWith("?")) {
- return resolveReferenceStartingWithQueryString(baseURI, reference);
+ return resolveReferenceStartingWithQueryString(baseURI, ref);
}
final boolean emptyReference = s.length() == 0;
if (emptyReference) {
- reference = URI.create("#");
+ ref = URI.create("#");
}
- URI resolved = baseURI.resolve(reference);
+ URI resolved = baseURI.resolve(ref);
if (emptyReference) {
final String resolvedString = resolved.toString();
resolved = URI.create(resolvedString.substring(0,
diff --git a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionOperator.java b/httpclient/src/main/java/org/apache/http/conn/ClientConnectionOperator.java
index d60266bf8..03d859dd4 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ClientConnectionOperator.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ClientConnectionOperator.java
@@ -29,18 +29,17 @@ package org.apache.http.conn;
import java.io.IOException;
import java.net.InetAddress;
-import java.net.Socket;
import org.apache.http.HttpHost;
-import org.apache.http.conn.scheme.SchemeSocketFactory;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.HttpContext;
/**
* ClientConnectionOperator represents a strategy for creating
* {@link OperatedClientConnection} instances and updating the underlying
- * {@link Socket} of those objects. Implementations will most likely make use
- * of {@link SchemeSocketFactory}s to create {@link Socket} instances.
+ * {@link java.net.Socket} of those objects. Implementations will most
+ * likely make use of {@link org.apache.http.conn.scheme.SchemeSocketFactory}s
+ * to create {@link java.net.Socket} instances.
*
* The methods in this interface allow the creation of plain and layered * sockets. Creating a tunnelled connection through a proxy, however, diff --git a/httpclient/src/main/java/org/apache/http/conn/ConnectTimeoutException.java b/httpclient/src/main/java/org/apache/http/conn/ConnectTimeoutException.java index 6eba40273..01d67381b 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ConnectTimeoutException.java +++ b/httpclient/src/main/java/org/apache/http/conn/ConnectTimeoutException.java @@ -30,7 +30,6 @@ package org.apache.http.conn; import java.io.IOException; import java.io.InterruptedIOException; import java.net.InetAddress; -import java.net.InetSocketAddress; import java.util.Arrays; import org.apache.http.HttpHost; diff --git a/httpclient/src/main/java/org/apache/http/conn/ConnectionKeepAliveStrategy.java b/httpclient/src/main/java/org/apache/http/conn/ConnectionKeepAliveStrategy.java index 762c44979..cbdb4a011 100644 --- a/httpclient/src/main/java/org/apache/http/conn/ConnectionKeepAliveStrategy.java +++ b/httpclient/src/main/java/org/apache/http/conn/ConnectionKeepAliveStrategy.java @@ -26,7 +26,6 @@ */ package org.apache.http.conn; -import org.apache.http.ConnectionReuseStrategy; import org.apache.http.HttpResponse; import org.apache.http.protocol.HttpContext; @@ -48,10 +47,11 @@ public interface ConnectionKeepAliveStrategy { * it MUST not reused. A value of 0 or less may be returned to indicate that * there is no suitable suggestion. * - * When coupled with a {@link ConnectionReuseStrategy}, if - * {@link ConnectionReuseStrategy#keepAlive(HttpResponse, HttpContext)} - * returns true, this allows you to control how long the reuse will last. If - * keepAlive returns false, this should have no meaningful impact + * When coupled with a {@link org.apache.http.ConnectionReuseStrategy}, if + * {@link org.apache.http.ConnectionReuseStrategy#keepAlive( + * HttpResponse, HttpContext)} returns true, this allows you to control + * how long the reuse will last. If keepAlive returns false, this should + * have no meaningful impact * * @param response * The last response received over the connection. diff --git a/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java b/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java index 7f536d090..454388570 100644 --- a/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java +++ b/httpclient/src/main/java/org/apache/http/conn/HttpHostConnectException.java @@ -29,7 +29,6 @@ package org.apache.http.conn; import java.io.IOException; import java.net.ConnectException; import java.net.InetAddress; -import java.net.InetSocketAddress; import java.util.Arrays; import org.apache.http.HttpHost; 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 4b9225413..2f1c10f7e 100644 --- a/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/MultihomePlainSocketFactory.java @@ -38,7 +38,6 @@ import java.util.Collections; import java.util.List; import org.apache.http.annotation.Immutable; -import org.apache.http.conn.scheme.SchemeSocketFactory; import org.apache.http.conn.scheme.SocketFactory; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; @@ -55,7 +54,7 @@ import org.apache.http.util.Asserts; * @since 4.0 * * @deprecated (4.1) Do not use. For multihome support socket factories must implement - * {@link SchemeSocketFactory} interface. + * {@link org.apache.http.conn.scheme.SchemeSocketFactory} interface. */ @Deprecated @Immutable @@ -93,7 +92,7 @@ public final class MultihomePlainSocketFactory implements SocketFactory { * given host name resolves to. If connection to all addresses fail, the * last I/O exception is propagated to the caller. * - * @param sock socket to connect to any of the given addresses + * @param socket socket to connect to any of the given addresses * @param host Host name to connect to * @param port the port to connect to * @param localAddress local address @@ -103,27 +102,21 @@ public final class MultihomePlainSocketFactory implements SocketFactory { * @throws IOException if an error occurs during the connection * @throws SocketTimeoutException if timeout expires before connecting */ - public Socket connectSocket(Socket sock, final String host, final int port, - final InetAddress localAddress, int localPort, + public Socket connectSocket(final Socket socket, final String host, final int port, + final InetAddress localAddress, final int localPort, final HttpParams params) throws IOException { Args.notNull(host, "Target host"); Args.notNull(params, "HTTP parameters"); + Socket sock = socket; if (sock == null) { sock = createSocket(); } if ((localAddress != null) || (localPort > 0)) { - - // we need to bind explicitly - if (localPort < 0) - { - localPort = 0; // indicates "any" - } - - final InetSocketAddress isa = - new InetSocketAddress(localAddress, localPort); + final InetSocketAddress isa = new InetSocketAddress(localAddress, + localPort > 0 ? localPort : 0); sock.bind(isa); } diff --git a/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java b/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java index 31f348c12..e80a907fc 100644 --- a/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java +++ b/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionPNames.java @@ -26,14 +26,13 @@ */ package org.apache.http.conn.params; -import org.apache.http.impl.conn.DefaultHttpResponseParser; - /** * Parameter names for HTTP client connections. * * @since 4.0 * - * @deprecated (4.1) use custom {@link DefaultHttpResponseParser} implementation. + * @deprecated (4.1) use custom {@link + * org.apache.http.impl.conn.DefaultHttpResponseParser} implementation. */ @Deprecated public interface ConnConnectionPNames { @@ -55,7 +54,8 @@ public interface ConnConnectionPNames { * Use {@link java.lang.Integer#MAX_VALUE} for unlimited number. *
* - * @deprecated (4.1) Use custom {@link DefaultHttpResponseParser} implementation + * @deprecated (4.1) Use custom {@link + * org.apache.http.impl.conn.DefaultHttpResponseParser} implementation */ @Deprecated public static final String MAX_STATUS_LINE_GARBAGE = "http.connection.max-status-line-garbage"; diff --git a/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionParamBean.java b/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionParamBean.java index 813725057..af85156d3 100644 --- a/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionParamBean.java +++ b/httpclient/src/main/java/org/apache/http/conn/params/ConnConnectionParamBean.java @@ -27,7 +27,6 @@ package org.apache.http.conn.params; -import org.apache.http.impl.conn.DefaultHttpResponseParser; import org.apache.http.params.HttpAbstractParamBean; import org.apache.http.params.HttpParams; @@ -38,7 +37,8 @@ import org.apache.http.params.HttpParams; * * @since 4.0 * - * @deprecated (4.2) do not use + * @deprecated (4.1) use custom {@link + * org.apache.http.impl.conn.DefaultHttpResponseParser} implementation. */ @Deprecated public class ConnConnectionParamBean extends HttpAbstractParamBean { @@ -48,7 +48,8 @@ public class ConnConnectionParamBean extends HttpAbstractParamBean { } /** - * @deprecated (4.2) Use custom {@link DefaultHttpResponseParser} implementation + * @deprecated (4.2) Use custom {@link + * org.apache.http.impl.conn.DefaultHttpResponseParser} implementation */ @Deprecated public void setMaxStatusLineGarbage (final int maxStatusLineGarbage) { diff --git a/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java b/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java index ad77be023..ff6af4e0a 100644 --- a/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java +++ b/httpclient/src/main/java/org/apache/http/conn/params/ConnManagerParams.java @@ -28,7 +28,6 @@ package org.apache.http.conn.params; import org.apache.http.annotation.Immutable; import org.apache.http.conn.routing.HttpRoute; -import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; import org.apache.http.util.Args; @@ -56,7 +55,8 @@ public final class ConnManagerParams implements ConnManagerPNames { * * @return timeout in milliseconds. * - * @deprecated (4.1) use {@link HttpConnectionParams#getConnectionTimeout(HttpParams)} + * @deprecated (4.1) use {@link + * org.apache.http.params.HttpConnectionParams#getConnectionTimeout(HttpParams)} */ @Deprecated public static long getTimeout(final HttpParams params) { @@ -71,7 +71,8 @@ public final class ConnManagerParams implements ConnManagerPNames { * * @param timeout the timeout in milliseconds * - * @deprecated (4.1) use {@link HttpConnectionParams#setConnectionTimeout(HttpParams, int)} + * @deprecated (4.1) use {@link + * org.apache.http.params.HttpConnectionParams#setConnectionTimeout(HttpParams, int)} */ @Deprecated public static void setTimeout(final HttpParams params, final long timeout) { diff --git a/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java b/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java index 29adcbf1f..6645ad72f 100644 --- a/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java +++ b/httpclient/src/main/java/org/apache/http/conn/params/ConnPerRouteBean.java @@ -31,7 +31,6 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.http.annotation.ThreadSafe; import org.apache.http.conn.routing.HttpRoute; -import org.apache.http.pool.ConnPoolControl; import org.apache.http.util.Args; /** @@ -42,7 +41,7 @@ import org.apache.http.util.Args; * * @since 4.0 * - * @deprecated (4.2) use {@link ConnPoolControl} + * @deprecated (4.2) use {@link org.apache.http.pool.ConnPoolControl} */ @Deprecated @ThreadSafe diff --git a/httpclient/src/main/java/org/apache/http/conn/params/ConnRoutePNames.java b/httpclient/src/main/java/org/apache/http/conn/params/ConnRoutePNames.java index 5a3ef6a67..cde8fbd97 100644 --- a/httpclient/src/main/java/org/apache/http/conn/params/ConnRoutePNames.java +++ b/httpclient/src/main/java/org/apache/http/conn/params/ConnRoutePNames.java @@ -26,14 +26,12 @@ */ package org.apache.http.conn.params; -import org.apache.http.client.config.RequestConfig; - /** * Parameter names for connection routing. * * @since 4.0 * - * @deprecated (4.3) use {@link RequestConfig}. + * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig}. */ @Deprecated public interface ConnRoutePNames { diff --git a/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParamBean.java b/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParamBean.java index 936c40e93..f574c7156 100644 --- a/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParamBean.java +++ b/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParamBean.java @@ -31,7 +31,6 @@ import java.net.InetAddress; import org.apache.http.HttpHost; import org.apache.http.annotation.NotThreadSafe; -import org.apache.http.client.config.RequestConfig; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.params.HttpAbstractParamBean; import org.apache.http.params.HttpParams; @@ -43,7 +42,7 @@ import org.apache.http.params.HttpParams; * * @since 4.0 * - * @deprecated (4.3) use {@link RequestConfig}. + * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig}. */ @Deprecated @NotThreadSafe diff --git a/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java b/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java index 524918aed..bf75bcece 100644 --- a/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java +++ b/httpclient/src/main/java/org/apache/http/conn/params/ConnRouteParams.java @@ -30,7 +30,6 @@ import java.net.InetAddress; import org.apache.http.HttpHost; import org.apache.http.annotation.Immutable; -import org.apache.http.client.config.RequestConfig; import org.apache.http.conn.routing.HttpRoute; import org.apache.http.params.HttpParams; import org.apache.http.util.Args; @@ -41,7 +40,7 @@ import org.apache.http.util.Args; * * @since 4.0 * - * @deprecated (4.3) use {@link RequestConfig}. + * @deprecated (4.3) use {@link org.apache.http.client.config.RequestConfig}. */ @Deprecated @Immutable 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 2cb1b4444..07f486ee0 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 @@ -92,7 +92,7 @@ public final class HttpRoute implements RouteInfo, Cloneable { private HttpRoute(final InetAddress local, final HttpHost target, final HttpHost[] proxies, final boolean secure, - TunnelType tunnelled, LayerType layered) { + final TunnelType tunnelled, final LayerType layered) { Args.notNull(target, "Target host"); Args.notNull(proxies, "Array of proxy hosts"); for (final HttpHost proxy: proxies) { @@ -101,23 +101,14 @@ public final class HttpRoute implements RouteInfo, Cloneable { if (tunnelled == TunnelType.TUNNELLED) { Args.check(proxies.length > 0, "Proxy required if tunnelled"); } - // tunnelled is already checked above, that is in line with the default - if (tunnelled == null) { - tunnelled = TunnelType.PLAIN; - } - if (layered == null) { - layered = LayerType.PLAIN; - } - this.targetHost = target; this.localAddress = local; this.proxyChain = proxies; this.secure = secure; - this.tunnelled = tunnelled; - this.layered = layered; + this.tunnelled = tunnelled != null ? tunnelled : TunnelType.PLAIN; + this.layered = layered != null ? layered : LayerType.PLAIN; } - /** * Creates a new route with all attributes specified explicitly. * diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java index 2952c3d91..f4ca592dd 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/PlainSocketFactory.java @@ -36,7 +36,6 @@ import java.net.UnknownHostException; import org.apache.http.annotation.Immutable; import org.apache.http.conn.ConnectTimeoutException; -import org.apache.http.conn.DnsResolver; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; import org.apache.http.util.Args; @@ -64,7 +63,7 @@ public class PlainSocketFactory implements SocketFactory, SchemeSocketFactory { } /** - * @deprecated (4.1) use {@link DnsResolver} + * @deprecated (4.1) use {@link org.apache.http.conn.DnsResolver} */ @Deprecated public PlainSocketFactory(final HostNameResolver nameResolver) { @@ -142,17 +141,13 @@ public class PlainSocketFactory implements SocketFactory, SchemeSocketFactory { public Socket connectSocket( final Socket socket, final String host, final int port, - final InetAddress localAddress, int localPort, + final InetAddress localAddress, final int localPort, final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException { InetSocketAddress local = null; if (localAddress != null || localPort > 0) { - // we need to bind explicitly - if (localPort < 0) { - localPort = 0; // indicates "any" - } - local = new InetSocketAddress(localAddress, localPort); + local = new InetSocketAddress(localAddress, localPort > 0 ? localPort : 0); } - InetAddress remoteAddress; + final InetAddress remoteAddress; if (this.nameResolver != null) { remoteAddress = this.nameResolver.resolve(host); } else { 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 3f3886458..4a6677361 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 @@ -29,8 +29,6 @@ package org.apache.http.conn.scheme; import java.util.Locale; import org.apache.http.annotation.Immutable; -import org.apache.http.config.Registry; -import org.apache.http.conn.SchemePortResolver; import org.apache.http.util.Args; import org.apache.http.util.LangUtils; @@ -48,8 +46,8 @@ import org.apache.http.util.LangUtils; * * @since 4.0 * - * @deprecated (4.3) use {@link SchemePortResolver} for default port resolution - * and {@link Registry} for socket factory lookups. + * @deprecated (4.3) use {@link org.apache.http.conn.SchemePortResolver} for default port + * resolution and {@link org.apache.http.config.Registry} for socket factory lookups. */ @Immutable @Deprecated diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeLayeredSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeLayeredSocketFactory.java index b06a36cf4..cf6c9e6b1 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeLayeredSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeLayeredSocketFactory.java @@ -31,7 +31,6 @@ import java.io.IOException; import java.net.Socket; import java.net.UnknownHostException; -import org.apache.http.conn.socket.LayeredConnectionSocketFactory; import org.apache.http.params.HttpParams; /** @@ -39,7 +38,8 @@ import org.apache.http.params.HttpParams; * * @since 4.2 * - * @deprecated (4.3) use {@link LayeredConnectionSocketFactory} + * @deprecated (4.3) use {@link + * org.apache.http.conn.socket.LayeredConnectionSocketFactory} */ @Deprecated public interface SchemeLayeredSocketFactory extends SchemeSocketFactory { diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java index 2d3934f52..99632a2e7 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeRegistry.java @@ -33,7 +33,6 @@ import java.util.concurrent.ConcurrentHashMap; import org.apache.http.HttpHost; import org.apache.http.annotation.ThreadSafe; -import org.apache.http.config.Registry; import org.apache.http.util.Args; /** @@ -42,7 +41,7 @@ import org.apache.http.util.Args; * * @since 4.0 * - * @deprecated (4.3) use {@link Registry} + * @deprecated (4.3) use {@link org.apache.http.config.Registry} */ @ThreadSafe @Deprecated diff --git a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactory.java index d124bc8e1..f2f1a7547 100644 --- a/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactory.java +++ b/httpclient/src/main/java/org/apache/http/conn/scheme/SchemeSocketFactory.java @@ -32,10 +32,7 @@ import java.net.InetSocketAddress; import java.net.Socket; import java.net.UnknownHostException; -import org.apache.http.HttpHost; import org.apache.http.conn.ConnectTimeoutException; -import org.apache.http.conn.HttpInetSocketAddress; -import org.apache.http.conn.socket.ConnectionSocketFactory; import org.apache.http.params.HttpParams; /** @@ -44,7 +41,7 @@ import org.apache.http.params.HttpParams; * * @since 4.1 * - * @deprecated (4.3) use {@link ConnectionSocketFactory} + * @deprecated (4.3) use {@link org.apache.http.conn.socket.ConnectionSocketFactory} */ @Deprecated public interface SchemeSocketFactory { @@ -70,10 +67,12 @@ public interface SchemeSocketFactory { /** * Connects a socket to the target host with the given remote address. * - * Please note that {@link HttpInetSocketAddress} class should be used in order to pass - * the target remote address along with the original {@link HttpHost} value used to resolve - * the address. The use of {@link HttpInetSocketAddress} can also ensure that no reverse - * DNS lookup will be performed if the target remote address was specified as an IP address. + * Please note that {@link org.apache.http.conn.HttpInetSocketAddress} class should + * be used in order to pass the target remote address along with the original + * {@link org.apache.http.HttpHost} value used to resolve the address. The use of + * {@link org.apache.http.conn.HttpInetSocketAddress} can also ensure that no reverse + * DNS lookup will be performed if the target remote address was specified + * as an IP address. * * @param sock the socket to connect, as obtained from * {@link #createSocket(HttpParams) createSocket}. @@ -94,7 +93,7 @@ public interface SchemeSocketFactory { * @throws ConnectTimeoutException if the socket cannot be connected * within the time limit defined in theparams
*
- * @see HttpInetSocketAddress
+ * @see org.apache.http.conn.HttpInetSocketAddress
*/
Socket connectSocket(
Socket sock,
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 61856e918..8e4a5cc21 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
@@ -37,9 +37,6 @@ import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.params.BasicHttpParams;
import org.apache.http.params.HttpParams;
-/**
- * @deprecated (4.1) do not use
- */
@Deprecated
class SocketFactoryAdaptor implements SocketFactory {
@@ -58,15 +55,11 @@ class SocketFactoryAdaptor implements SocketFactory {
public Socket connectSocket(
final Socket socket,
final String host, final int port,
- final InetAddress localAddress, int localPort,
+ final InetAddress localAddress, final int localPort,
final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
InetSocketAddress local = null;
if (localAddress != null || localPort > 0) {
- // we need to bind explicitly
- if (localPort < 0) {
- localPort = 0; // indicates "any"
- }
- local = new InetSocketAddress(localAddress, localPort);
+ local = new InetSocketAddress(localAddress, localPort > 0 ? localPort : 0);
}
final InetAddress remoteAddress = InetAddress.getByName(host);
final InetSocketAddress remote = new InetSocketAddress(remoteAddress, port);
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 133107689..5e4c111e2 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
@@ -295,7 +295,7 @@ public abstract class AbstractVerifier implements X509HostnameVerifier {
*/
private static String[] getSubjectAlts(
final X509Certificate cert, final String hostname) {
- int subjectType;
+ final int subjectType;
if (isIPAddress(hostname)) {
subjectType = 7;
} else {
@@ -375,7 +375,7 @@ public abstract class AbstractVerifier implements X509HostnameVerifier {
return hostname;
}
try {
- InetAddress inetAddress = InetAddress.getByName(hostname);
+ final InetAddress inetAddress = InetAddress.getByName(hostname);
return inetAddress.getHostAddress();
} catch (UnknownHostException uhe) { // Should not happen, because we check for IPv6 address above
log.error("Unexpected error converting "+hostname, uhe);
diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLContexts.java b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLContexts.java
index 489bdf415..87a17a711 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLContexts.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLContexts.java
@@ -49,7 +49,7 @@ public class SSLContexts {
*
* @return the default SSL socket factory
*/
- public static final SSLContext createDefault() throws SSLInitializationException {
+ public static SSLContext createDefault() throws SSLInitializationException {
try {
final SSLContext sslcontext = SSLContext.getInstance(SSLContextBuilder.TLS);
sslcontext.init(null, null, null);
@@ -70,7 +70,7 @@ public class SSLContexts {
*
* @return default system SSL context
*/
- public static final SSLContext createSystemDefault() throws SSLInitializationException {
+ public static SSLContext createSystemDefault() throws SSLInitializationException {
try {
return SSLContext.getInstance("Default");
} catch (final NoSuchAlgorithmException ex) {
@@ -83,7 +83,7 @@ public class SSLContexts {
*
* @return default system SSL context
*/
- public static final SSLContextBuilder custom() {
+ public static SSLContextBuilder custom() {
return new SSLContextBuilder();
}
diff --git a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
index b7575242d..325f09974 100644
--- a/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
+++ b/httpclient/src/main/java/org/apache/http/conn/ssl/SSLSocketFactory.java
@@ -28,11 +28,9 @@
package org.apache.http.conn.ssl;
import java.io.IOException;
-import java.net.ConnectException;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Socket;
-import java.net.SocketTimeoutException;
import java.net.UnknownHostException;
import java.security.KeyManagementException;
import java.security.KeyStore;
@@ -166,6 +164,7 @@ public class SSLSocketFactory implements LayeredConnectionSocketFactory, SchemeL
throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
this(SSLContexts.custom()
.useProtocol(algorithm)
+ .setSecureRandom(random)
.loadKeyMaterial(keystore, keyPassword != null ? keyPassword.toCharArray() : null)
.loadTrustMaterial(truststore)
.build(),
@@ -190,6 +189,7 @@ public class SSLSocketFactory implements LayeredConnectionSocketFactory, SchemeL
throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
this(SSLContexts.custom()
.useProtocol(algorithm)
+ .setSecureRandom(random)
.loadKeyMaterial(keystore, keyPassword != null ? keyPassword.toCharArray() : null)
.loadTrustMaterial(truststore, trustStrategy)
.build(),
@@ -213,6 +213,7 @@ public class SSLSocketFactory implements LayeredConnectionSocketFactory, SchemeL
throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
this(SSLContexts.custom()
.useProtocol(algorithm)
+ .setSecureRandom(random)
.loadKeyMaterial(keystore, keyPassword != null ? keyPassword.toCharArray() : null)
.loadTrustMaterial(truststore)
.build(),
@@ -392,7 +393,7 @@ public class SSLSocketFactory implements LayeredConnectionSocketFactory, SchemeL
final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
Args.notNull(remoteAddress, "Remote address");
Args.notNull(params, "HTTP parameters");
- HttpHost host;
+ final HttpHost host;
if (remoteAddress instanceof HttpInetSocketAddress) {
host = ((HttpInetSocketAddress) remoteAddress).getHttpHost();
} else {
@@ -473,9 +474,9 @@ public class SSLSocketFactory implements LayeredConnectionSocketFactory, SchemeL
public Socket connectSocket(
final Socket socket,
final String host, final int port,
- final InetAddress local, int localPort,
+ final InetAddress local, final int localPort,
final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
- InetAddress remote;
+ final InetAddress remote;
if (this.nameResolver != null) {
remote = this.nameResolver.resolve(host);
} else {
@@ -483,11 +484,7 @@ public class SSLSocketFactory implements LayeredConnectionSocketFactory, SchemeL
}
InetSocketAddress localAddress = null;
if (local != null || localPort > 0) {
- // we need to bind explicitly
- if (localPort < 0) {
- localPort = 0; // indicates "any"
- }
- localAddress = new InetSocketAddress(local, localPort);
+ localAddress = new InetSocketAddress(local, localPort > 0 ? localPort : 0);
}
final InetSocketAddress remoteAddress = new HttpInetSocketAddress(
new HttpHost(host, port), remote, port);
diff --git a/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java b/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
index 70beb03ef..d66e3ad46 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/CookieSpecRegistry.java
@@ -36,7 +36,6 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.http.HttpRequest;
import org.apache.http.annotation.ThreadSafe;
import org.apache.http.config.Lookup;
-import org.apache.http.config.Registry;
import org.apache.http.params.HttpParams;
import org.apache.http.protocol.ExecutionContext;
import org.apache.http.protocol.HttpContext;
@@ -49,7 +48,7 @@ import org.apache.http.util.Args;
*
* @since 4.0
*
- * @deprecated (4.3) use {@link Registry}.
+ * @deprecated (4.3) use {@link org.apache.http.config.Registry}.
*/
@ThreadSafe
@Deprecated
diff --git a/httpclient/src/main/java/org/apache/http/cookie/params/CookieSpecPNames.java b/httpclient/src/main/java/org/apache/http/cookie/params/CookieSpecPNames.java
index cc60aaebd..8d7d80197 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/params/CookieSpecPNames.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/params/CookieSpecPNames.java
@@ -27,14 +27,13 @@
package org.apache.http.cookie.params;
-import org.apache.http.cookie.CookieSpecProvider;
-
/**
* Parameter names for HTTP cookie management classes.
*
* @since 4.0
*
- * @deprecated (4.3) use constructor parameters of {@link CookieSpecProvider}s.
+ * @deprecated (4.3) use constructor parameters of {@link
+ * org.apache.http.cookie.CookieSpecProvider}s.
*/
@Deprecated
public interface CookieSpecPNames {
diff --git a/httpclient/src/main/java/org/apache/http/cookie/params/CookieSpecParamBean.java b/httpclient/src/main/java/org/apache/http/cookie/params/CookieSpecParamBean.java
index 1b9cfbeb4..ea6a9299e 100644
--- a/httpclient/src/main/java/org/apache/http/cookie/params/CookieSpecParamBean.java
+++ b/httpclient/src/main/java/org/apache/http/cookie/params/CookieSpecParamBean.java
@@ -30,7 +30,6 @@ package org.apache.http.cookie.params;
import java.util.Collection;
import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.cookie.CookieSpecProvider;
import org.apache.http.params.HttpAbstractParamBean;
import org.apache.http.params.HttpParams;
@@ -41,7 +40,8 @@ import org.apache.http.params.HttpParams;
*
* @since 4.0
*
- * @deprecated (4.3) use constructor parameters of {@link CookieSpecProvider}s.
+ * @deprecated (4.3) use constructor parameters of {@link
+ * org.apache.http.cookie.CookieSpecProvider}s.
*/
@Deprecated
@NotThreadSafe
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java b/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
index 783a2e483..e84185646 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/AuthSchemeBase.java
@@ -97,7 +97,7 @@ public abstract class AuthSchemeBase implements ContextAwareAuthScheme {
throw new MalformedChallengeException("Unexpected header name: " + authheader);
}
- CharArrayBuffer buffer;
+ final CharArrayBuffer buffer;
int pos;
if (header instanceof FormattedHeader) {
buffer = ((FormattedHeader) header).getBuffer();
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java
index b64b2b86a..92cd96466 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/BasicScheme.java
@@ -36,9 +36,7 @@ import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.ChallengeState;
-import org.apache.http.auth.ContextAwareAuthScheme;
import org.apache.http.auth.Credentials;
-import org.apache.http.auth.InvalidCredentialsException;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.message.BufferedHeader;
import org.apache.http.protocol.BasicHttpContext;
@@ -130,7 +128,8 @@ public class BasicScheme extends RFC2617Scheme {
}
/**
- * @deprecated (4.2) Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
+ * @deprecated (4.2) Use {@link org.apache.http.auth.ContextAwareAuthScheme#authenticate(
+ * Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
*/
@Deprecated
public Header authenticate(
@@ -143,8 +142,8 @@ public class BasicScheme extends RFC2617Scheme {
*
* @param credentials The set of credentials to be used for authentication
* @param request The request being authenticated
- * @throws InvalidCredentialsException if authentication credentials are not
- * valid or not applicable for this authentication scheme
+ * @throws org.apache.http.auth.InvalidCredentialsException if authentication
+ * credentials are not valid or not applicable for this authentication scheme
* @throws AuthenticationException if authorization string cannot
* be generated due to an authentication failure
*
diff --git a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
index 0290a3596..3973f9b33 100644
--- a/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
+++ b/httpclient/src/main/java/org/apache/http/impl/auth/DigestScheme.java
@@ -47,7 +47,6 @@ import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.ChallengeState;
-import org.apache.http.auth.ContextAwareAuthScheme;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.message.BasicHeaderValueFormatter;
@@ -178,7 +177,8 @@ public class DigestScheme extends RFC2617Scheme {
}
/**
- * @deprecated (4.2) Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
+ * @deprecated (4.2) Use {@link org.apache.http.auth.ContextAwareAuthScheme#authenticate(
+ * Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
*/
@Deprecated
public Header authenticate(
@@ -288,7 +288,7 @@ public class DigestScheme extends RFC2617Scheme {
digAlg = "MD5";
}
- MessageDigest digester;
+ final MessageDigest digester;
try {
digester = createMessageDigest(digAlg);
} catch (final UnsupportedDigestAlgorithmException ex) {
@@ -377,7 +377,7 @@ public class DigestScheme extends RFC2617Scheme {
// 3.2.2.1
- String digestValue;
+ final String digestValue;
if (qop == QOP_MISSING) {
sb.setLength(0);
sb.append(hasha1).append(':').append(nonce).append(':').append(hasha2);
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 e452acd9d..f50e21267 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
@@ -34,7 +34,6 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.auth.AUTH;
import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.ContextAwareAuthScheme;
import org.apache.http.auth.Credentials;
import org.apache.http.auth.InvalidCredentialsException;
import org.apache.http.auth.MalformedChallengeException;
@@ -111,7 +110,8 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
}
/**
- * @deprecated (4.2) Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
+ * @deprecated (4.2) Use {@link org.apache.http.auth.ContextAwareAuthScheme#authenticate(
+ * Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
*/
@Deprecated
public Header authenticate(
@@ -146,7 +146,7 @@ public abstract class GGSSchemeBase extends AuthSchemeBase {
} else {
host = route.getTargetHost();
}
- String authServer;
+ final String authServer;
if (!this.stripPort && host.getPort() > 0) {
authServer = host.toHostString();
} else {
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 9b3ce86fa..e1a1d5ecf 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
@@ -72,7 +72,7 @@ final class NTLMEngineImpl implements NTLMEngine {
java.security.SecureRandom rnd = null;
try {
rnd = java.security.SecureRandom.getInstance("SHA1PRNG");
- } catch (Exception e) {
+ } catch (Exception ignore) {
}
RND_GEN = rnd;
}
@@ -84,10 +84,10 @@ final class NTLMEngineImpl implements NTLMEngine {
private String credentialCharset = DEFAULT_CHARSET;
/** The signature string as bytes in the default encoding */
- private static byte[] SIGNATURE;
+ private static final byte[] SIGNATURE;
static {
- byte[] bytesWithoutNull = EncodingUtils.getBytes("NTLMSSP", "ASCII");
+ final byte[] bytesWithoutNull = EncodingUtils.getBytes("NTLMSSP", "ASCII");
SIGNATURE = new byte[bytesWithoutNull.length + 1];
System.arraycopy(bytesWithoutNull, 0, SIGNATURE, 0, bytesWithoutNull.length);
SIGNATURE[bytesWithoutNull.length] = (byte) 0x00;
@@ -107,17 +107,17 @@ final class NTLMEngineImpl implements NTLMEngine {
* @param domain
* the NT domain to authenticate in.
* @return The response.
- * @throws HttpException
+ * @throws org.apache.http.HttpException
* If the messages cannot be retrieved.
*/
- final String getResponseFor(String message, String username, String password,
- String host, String domain) throws NTLMEngineException {
+ final String getResponseFor(final String message, final String username, final String password,
+ final String host, final String domain) throws NTLMEngineException {
final String response;
if (message == null || message.trim().equals("")) {
response = getType1Message(host, domain);
} else {
- Type2Message t2m = new Type2Message(message);
+ final Type2Message t2m = new Type2Message(message);
response = getType3Message(username, password, host, domain, t2m.getChallenge(), t2m
.getFlags(), t2m.getTarget(), t2m.getTargetInfo());
}
@@ -135,7 +135,7 @@ final class NTLMEngineImpl implements NTLMEngine {
* The domain to authenticate with.
* @return String the message to add to the HTTP request header.
*/
- String getType1Message(String host, String domain) throws NTLMEngineException {
+ String getType1Message(final String host, final String domain) throws NTLMEngineException {
return new Type1Message(domain, host).getResponse();
}
@@ -159,8 +159,8 @@ final class NTLMEngineImpl implements NTLMEngine {
* @throws NTLMEngineException
* If {@encrypt(byte[],byte[])} fails.
*/
- String getType3Message(String user, String password, String host, String domain,
- byte[] nonce, int type2Flags, String target, byte[] targetInformation)
+ String getType3Message(final String user, final String password, final String host, final String domain,
+ final byte[] nonce, final int type2Flags, final String target, final byte[] targetInformation)
throws NTLMEngineException {
return new Type3Message(domain, host, user, password, nonce, type2Flags, target,
targetInformation).getResponse();
@@ -177,48 +177,48 @@ final class NTLMEngineImpl implements NTLMEngine {
* @param credentialCharset
* The credentialCharset to set.
*/
- void setCredentialCharset(String credentialCharset) {
+ void setCredentialCharset(final String credentialCharset) {
this.credentialCharset = credentialCharset;
}
/** Strip dot suffix from a name */
- private static String stripDotSuffix(String value) {
- int index = value.indexOf(".");
+ private static String stripDotSuffix(final String value) {
+ final int index = value.indexOf(".");
if (index != -1)
return value.substring(0, index);
return value;
}
/** Convert host to standard form */
- private static String convertHost(String host) {
+ private static String convertHost(final String host) {
return stripDotSuffix(host);
}
/** Convert domain to standard form */
- private static String convertDomain(String domain) {
+ private static String convertDomain(final String domain) {
return stripDotSuffix(domain);
}
- private static int readULong(byte[] src, int index) throws NTLMEngineException {
+ 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");
return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8)
| ((src[index + 2] & 0xff) << 16) | ((src[index + 3] & 0xff) << 24);
}
- private static int readUShort(byte[] src, int index) throws NTLMEngineException {
+ 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");
return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8);
}
- private static byte[] readSecurityBuffer(byte[] src, int index) throws NTLMEngineException {
- int length = readUShort(src, index);
- int offset = readULong(src, index + 4);
+ private static byte[] readSecurityBuffer(final byte[] src, final int index) throws NTLMEngineException {
+ final int length = readUShort(src, index);
+ final int offset = readULong(src, index + 4);
if (src.length < offset + length)
throw new NTLMEngineException(
"NTLM authentication - buffer too small for data item");
- byte[] buffer = new byte[length];
+ final byte[] buffer = new byte[length];
System.arraycopy(src, offset, buffer, 0, length);
return buffer;
}
@@ -228,7 +228,7 @@ final class NTLMEngineImpl implements NTLMEngine {
if (RND_GEN == null) {
throw new NTLMEngineException("Random generator not available");
}
- byte[] rval = new byte[8];
+ final byte[] rval = new byte[8];
synchronized (RND_GEN) {
RND_GEN.nextBytes(rval);
}
@@ -240,7 +240,7 @@ final class NTLMEngineImpl implements NTLMEngine {
if (RND_GEN == null) {
throw new NTLMEngineException("Random generator not available");
}
- byte[] rval = new byte[16];
+ final byte[] rval = new byte[16];
synchronized (RND_GEN) {
RND_GEN.nextBytes(rval);
}
@@ -280,10 +280,10 @@ final class NTLMEngineImpl implements NTLMEngine {
protected byte[] ntlm2SessionResponseUserSessionKey = null;
protected byte[] lanManagerSessionKey = null;
- public CipherGen(String domain, String user, String password,
- byte[] challenge, String target, byte[] targetInformation,
- byte[] clientChallenge, byte[] clientChallenge2,
- byte[] secondaryKey, byte[] timestamp) {
+ public CipherGen(final String domain, final String user, final String password,
+ final byte[] challenge, final String target, final byte[] targetInformation,
+ final byte[] clientChallenge, final byte[] clientChallenge2,
+ final byte[] secondaryKey, final byte[] timestamp) {
this.domain = domain;
this.target = target;
this.user = user;
@@ -296,8 +296,8 @@ final class NTLMEngineImpl implements NTLMEngine {
this.timestamp = timestamp;
}
- public CipherGen(String domain, String user, String password,
- byte[] challenge, String target, byte[] targetInformation) {
+ public CipherGen(final String domain, final String user, final String password,
+ final byte[] challenge, final String target, final byte[] targetInformation) {
this(domain, user, password, challenge, target, targetInformation, null, null, null, null);
}
@@ -425,7 +425,7 @@ final class NTLMEngineImpl implements NTLMEngine {
public byte[] getLM2SessionResponse()
throws NTLMEngineException {
if (lm2SessionResponse == null) {
- byte[] clientChallenge = getClientChallenge();
+ final byte[] clientChallenge = getClientChallenge();
lm2SessionResponse = new byte[24];
System.arraycopy(clientChallenge, 0, lm2SessionResponse, 0, clientChallenge.length);
Arrays.fill(lm2SessionResponse, clientChallenge.length, lm2SessionResponse.length, (byte) 0x00);
@@ -437,7 +437,7 @@ final class NTLMEngineImpl implements NTLMEngine {
public byte[] getLMUserSessionKey()
throws NTLMEngineException {
if (lmUserSessionKey == null) {
- byte[] lmHash = getLMHash();
+ final byte[] lmHash = getLMHash();
lmUserSessionKey = new byte[16];
System.arraycopy(lmHash, 0, lmUserSessionKey, 0, 8);
Arrays.fill(lmUserSessionKey, 8, 16, (byte) 0x00);
@@ -449,8 +449,8 @@ final class NTLMEngineImpl implements NTLMEngine {
public byte[] getNTLMUserSessionKey()
throws NTLMEngineException {
if (ntlmUserSessionKey == null) {
- byte[] ntlmHash = getNTLMHash();
- MD4 md4 = new MD4();
+ final byte[] ntlmHash = getNTLMHash();
+ final MD4 md4 = new MD4();
md4.update(ntlmHash);
ntlmUserSessionKey = md4.getOutput();
}
@@ -461,8 +461,8 @@ final class NTLMEngineImpl implements NTLMEngine {
public byte[] getNTLMv2UserSessionKey()
throws NTLMEngineException {
if (ntlmv2UserSessionKey == null) {
- byte[] ntlmv2hash = getNTLMv2Hash();
- byte[] truncatedResponse = new byte[16];
+ final byte[] ntlmv2hash = getNTLMv2Hash();
+ final byte[] truncatedResponse = new byte[16];
System.arraycopy(getNTLMv2Response(), 0, truncatedResponse, 0, 16);
ntlmv2UserSessionKey = hmacMD5(truncatedResponse, ntlmv2hash);
}
@@ -473,9 +473,9 @@ final class NTLMEngineImpl implements NTLMEngine {
public byte[] getNTLM2SessionResponseUserSessionKey()
throws NTLMEngineException {
if (ntlm2SessionResponseUserSessionKey == null) {
- byte[] ntlmUserSessionKey = getNTLMUserSessionKey();
- byte[] ntlm2SessionResponseNonce = getLM2SessionResponse();
- byte[] sessionNonce = new byte[challenge.length + ntlm2SessionResponseNonce.length];
+ final byte[] ntlmUserSessionKey = getNTLMUserSessionKey();
+ final byte[] ntlm2SessionResponseNonce = getLM2SessionResponse();
+ final byte[] sessionNonce = new byte[challenge.length + ntlm2SessionResponseNonce.length];
System.arraycopy(challenge, 0, sessionNonce, 0, challenge.length);
System.arraycopy(ntlm2SessionResponseNonce, 0, sessionNonce, challenge.length, ntlm2SessionResponseNonce.length);
ntlm2SessionResponseUserSessionKey = hmacMD5(sessionNonce,ntlmUserSessionKey);
@@ -487,22 +487,22 @@ final class NTLMEngineImpl implements NTLMEngine {
public byte[] getLanManagerSessionKey()
throws NTLMEngineException {
if (lanManagerSessionKey == null) {
- byte[] lmHash = getLMHash();
- byte[] lmResponse = getLMResponse();
+ final byte[] lmHash = getLMHash();
+ final byte[] lmResponse = getLMResponse();
try {
- byte[] keyBytes = new byte[14];
+ final byte[] keyBytes = new byte[14];
System.arraycopy(lmHash, 0, keyBytes, 0, 8);
Arrays.fill(keyBytes, 8, keyBytes.length, (byte)0xbd);
- Key lowKey = createDESKey(keyBytes, 0);
- Key highKey = createDESKey(keyBytes, 7);
- byte[] truncatedResponse = new byte[8];
+ final Key lowKey = createDESKey(keyBytes, 0);
+ final Key highKey = createDESKey(keyBytes, 7);
+ final byte[] truncatedResponse = new byte[8];
System.arraycopy(lmResponse, 0, truncatedResponse, 0, truncatedResponse.length);
Cipher des = Cipher.getInstance("DES/ECB/NoPadding");
des.init(Cipher.ENCRYPT_MODE, lowKey);
- byte[] lowPart = des.doFinal(truncatedResponse);
+ final byte[] lowPart = des.doFinal(truncatedResponse);
des = Cipher.getInstance("DES/ECB/NoPadding");
des.init(Cipher.ENCRYPT_MODE, highKey);
- byte[] highPart = des.doFinal(truncatedResponse);
+ final byte[] highPart = des.doFinal(truncatedResponse);
lanManagerSessionKey = new byte[16];
System.arraycopy(lowPart, 0, lanManagerSessionKey, 0, lowPart.length);
System.arraycopy(highPart, 0, lanManagerSessionKey, lowPart.length, highPart.length);
@@ -515,18 +515,18 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Calculates HMAC-MD5 */
- static byte[] hmacMD5(byte[] value, byte[] key)
+ static byte[] hmacMD5(final byte[] value, final byte[] key)
throws NTLMEngineException {
- HMACMD5 hmacMD5 = new HMACMD5(key);
+ final HMACMD5 hmacMD5 = new HMACMD5(key);
hmacMD5.update(value);
return hmacMD5.getOutput();
}
/** Calculates RC4 */
- static byte[] RC4(byte[] value, byte[] key)
+ static byte[] RC4(final byte[] value, final byte[] key)
throws NTLMEngineException {
try {
- Cipher rc4 = Cipher.getInstance("RC4");
+ final Cipher rc4 = Cipher.getInstance("RC4");
rc4.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "RC4"));
return rc4.doFinal(value);
} catch (Exception e) {
@@ -538,19 +538,12 @@ final class NTLMEngineImpl implements NTLMEngine {
* Calculates the NTLM2 Session Response for the given challenge, using the
* specified password and client challenge.
*
- * @param password
- * The user's password.
- * @param challenge
- * The Type 2 challenge from the server.
- * @param clientChallenge
- * The random 8-byte client challenge.
- *
* @return The NTLM2 Session Response. This is placed in the NTLM response
* field of the Type 3 message; the LM response field contains the
* client challenge, null-padded to 24 bytes.
*/
- static byte[] ntlm2SessionResponse(byte[] ntlmHash, byte[] challenge,
- byte[] clientChallenge) throws NTLMEngineException {
+ static byte[] ntlm2SessionResponse(final byte[] ntlmHash, final byte[] challenge,
+ final byte[] clientChallenge) throws NTLMEngineException {
try {
// Look up MD5 algorithm (was necessary on jdk 1.4.2)
// This used to be needed, but java 1.5.0_07 includes the MD5
@@ -565,12 +558,12 @@ final class NTLMEngineImpl implements NTLMEngine {
// byte[] digest = (byte[])digestMethod.invoke(mdInstance,new
// Object[0]);
- MessageDigest md5 = MessageDigest.getInstance("MD5");
+ final MessageDigest md5 = MessageDigest.getInstance("MD5");
md5.update(challenge);
md5.update(clientChallenge);
- byte[] digest = md5.digest();
+ final byte[] digest = md5.digest();
- byte[] sessionHash = new byte[8];
+ final byte[] sessionHash = new byte[8];
System.arraycopy(digest, 0, sessionHash, 0, 8);
return lmResponse(ntlmHash, sessionHash);
} catch (Exception e) {
@@ -589,21 +582,21 @@ final class NTLMEngineImpl implements NTLMEngine {
* @return The LM Hash of the given password, used in the calculation of the
* LM Response.
*/
- private static byte[] lmHash(String password) throws NTLMEngineException {
+ private static byte[] lmHash(final String password) throws NTLMEngineException {
try {
- byte[] oemPassword = password.toUpperCase(Locale.US).getBytes("US-ASCII");
- int length = Math.min(oemPassword.length, 14);
- byte[] keyBytes = new byte[14];
+ final byte[] oemPassword = password.toUpperCase(Locale.US).getBytes("US-ASCII");
+ final int length = Math.min(oemPassword.length, 14);
+ final byte[] keyBytes = new byte[14];
System.arraycopy(oemPassword, 0, keyBytes, 0, length);
- Key lowKey = createDESKey(keyBytes, 0);
- Key highKey = createDESKey(keyBytes, 7);
- byte[] magicConstant = "KGS!@#$%".getBytes("US-ASCII");
- Cipher des = Cipher.getInstance("DES/ECB/NoPadding");
+ final Key lowKey = createDESKey(keyBytes, 0);
+ final Key highKey = createDESKey(keyBytes, 7);
+ final byte[] magicConstant = "KGS!@#$%".getBytes("US-ASCII");
+ final Cipher des = Cipher.getInstance("DES/ECB/NoPadding");
des.init(Cipher.ENCRYPT_MODE, lowKey);
- byte[] lowHash = des.doFinal(magicConstant);
+ final byte[] lowHash = des.doFinal(magicConstant);
des.init(Cipher.ENCRYPT_MODE, highKey);
- byte[] highHash = des.doFinal(magicConstant);
- byte[] lmHash = new byte[16];
+ final byte[] highHash = des.doFinal(magicConstant);
+ final byte[] lmHash = new byte[16];
System.arraycopy(lowHash, 0, lmHash, 0, 8);
System.arraycopy(highHash, 0, lmHash, 8, 8);
return lmHash;
@@ -621,10 +614,10 @@ final class NTLMEngineImpl implements NTLMEngine {
* @return The NTLM Hash of the given password, used in the calculation of
* the NTLM Response and the NTLMv2 and LMv2 Hashes.
*/
- private static byte[] ntlmHash(String password) throws NTLMEngineException {
+ private static byte[] ntlmHash(final String password) throws NTLMEngineException {
try {
- byte[] unicodePassword = password.getBytes("UnicodeLittleUnmarked");
- MD4 md4 = new MD4();
+ final byte[] unicodePassword = password.getBytes("UnicodeLittleUnmarked");
+ final MD4 md4 = new MD4();
md4.update(unicodePassword);
return md4.getOutput();
} catch (java.io.UnsupportedEncodingException e) {
@@ -635,20 +628,13 @@ final class NTLMEngineImpl implements NTLMEngine {
/**
* Creates the LMv2 Hash of the user's password.
*
- * @param target
- * The authentication target (i.e., domain).
- * @param user
- * The username.
- * @param password
- * The password.
- *
* @return The LMv2 Hash, used in the calculation of the NTLMv2 and LMv2
* Responses.
*/
- private static byte[] lmv2Hash(String domain, String user, byte[] ntlmHash)
+ private static byte[] lmv2Hash(final String domain, final String user, final byte[] ntlmHash)
throws NTLMEngineException {
try {
- HMACMD5 hmacMD5 = new HMACMD5(ntlmHash);
+ final HMACMD5 hmacMD5 = new HMACMD5(ntlmHash);
// Upper case username, upper case domain!
hmacMD5.update(user.toUpperCase(Locale.US).getBytes("UnicodeLittleUnmarked"));
hmacMD5.update(domain.toUpperCase(Locale.US).getBytes("UnicodeLittleUnmarked"));
@@ -661,20 +647,13 @@ final class NTLMEngineImpl implements NTLMEngine {
/**
* Creates the NTLMv2 Hash of the user's password.
*
- * @param target
- * The authentication target (i.e., domain).
- * @param user
- * The username.
- * @param password
- * The password.
- *
* @return The NTLMv2 Hash, used in the calculation of the NTLMv2 and LMv2
* Responses.
*/
- private static byte[] ntlmv2Hash(String domain, String user, byte[] ntlmHash)
+ private static byte[] ntlmv2Hash(final String domain, final String user, final byte[] ntlmHash)
throws NTLMEngineException {
try {
- HMACMD5 hmacMD5 = new HMACMD5(ntlmHash);
+ final HMACMD5 hmacMD5 = new HMACMD5(ntlmHash);
// Upper case username, mixed case target!!
hmacMD5.update(user.toUpperCase(Locale.US).getBytes("UnicodeLittleUnmarked"));
hmacMD5.update(domain.getBytes("UnicodeLittleUnmarked"));
@@ -694,21 +673,21 @@ final class NTLMEngineImpl implements NTLMEngine {
*
* @return The response (either LM or NTLM, depending on the provided hash).
*/
- private static byte[] lmResponse(byte[] hash, byte[] challenge) throws NTLMEngineException {
+ private static byte[] lmResponse(final byte[] hash, final byte[] challenge) throws NTLMEngineException {
try {
- byte[] keyBytes = new byte[21];
+ final byte[] keyBytes = new byte[21];
System.arraycopy(hash, 0, keyBytes, 0, 16);
- Key lowKey = createDESKey(keyBytes, 0);
- Key middleKey = createDESKey(keyBytes, 7);
- Key highKey = createDESKey(keyBytes, 14);
- Cipher des = Cipher.getInstance("DES/ECB/NoPadding");
+ final Key lowKey = createDESKey(keyBytes, 0);
+ final Key middleKey = createDESKey(keyBytes, 7);
+ final Key highKey = createDESKey(keyBytes, 14);
+ final Cipher des = Cipher.getInstance("DES/ECB/NoPadding");
des.init(Cipher.ENCRYPT_MODE, lowKey);
- byte[] lowResponse = des.doFinal(challenge);
+ final byte[] lowResponse = des.doFinal(challenge);
des.init(Cipher.ENCRYPT_MODE, middleKey);
- byte[] middleResponse = des.doFinal(challenge);
+ final byte[] middleResponse = des.doFinal(challenge);
des.init(Cipher.ENCRYPT_MODE, highKey);
- byte[] highResponse = des.doFinal(challenge);
- byte[] lmResponse = new byte[24];
+ final byte[] highResponse = des.doFinal(challenge);
+ final byte[] lmResponse = new byte[24];
System.arraycopy(lowResponse, 0, lmResponse, 0, 8);
System.arraycopy(middleResponse, 0, lmResponse, 8, 8);
System.arraycopy(highResponse, 0, lmResponse, 16, 8);
@@ -732,13 +711,13 @@ final class NTLMEngineImpl implements NTLMEngine {
* @return The response (either NTLMv2 or LMv2, depending on the client
* data).
*/
- private static byte[] lmv2Response(byte[] hash, byte[] challenge, byte[] clientData)
+ private static byte[] lmv2Response(final byte[] hash, final byte[] challenge, final byte[] clientData)
throws NTLMEngineException {
- HMACMD5 hmacMD5 = new HMACMD5(hash);
+ final HMACMD5 hmacMD5 = new HMACMD5(hash);
hmacMD5.update(challenge);
hmacMD5.update(clientData);
- byte[] mac = hmacMD5.getOutput();
- byte[] lmv2Response = new byte[mac.length + clientData.length];
+ final byte[] mac = hmacMD5.getOutput();
+ final byte[] lmv2Response = new byte[mac.length + clientData.length];
System.arraycopy(mac, 0, lmv2Response, 0, mac.length);
System.arraycopy(clientData, 0, lmv2Response, mac.length, clientData.length);
return lmv2Response;
@@ -755,12 +734,12 @@ final class NTLMEngineImpl implements NTLMEngine {
*
* @return The blob, used in the calculation of the NTLMv2 Response.
*/
- private static byte[] createBlob(byte[] clientChallenge, byte[] targetInformation, byte[] timestamp) {
- byte[] blobSignature = new byte[] { (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00 };
- byte[] reserved = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
- byte[] unknown1 = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
- byte[] unknown2 = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
- byte[] blob = new byte[blobSignature.length + reserved.length + timestamp.length + 8
+ private static byte[] createBlob(final byte[] clientChallenge, final byte[] targetInformation, final byte[] timestamp) {
+ final byte[] blobSignature = new byte[] { (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00 };
+ final byte[] reserved = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
+ final byte[] unknown1 = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
+ final byte[] unknown2 = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
+ final byte[] blob = new byte[blobSignature.length + reserved.length + timestamp.length + 8
+ unknown1.length + targetInformation.length + unknown2.length];
int offset = 0;
System.arraycopy(blobSignature, 0, blob, offset, blobSignature.length);
@@ -792,10 +771,10 @@ final class NTLMEngineImpl implements NTLMEngine {
* @return A DES encryption key created from the key material starting at
* the specified offset in the given byte array.
*/
- private static Key createDESKey(byte[] bytes, int offset) {
- byte[] keyBytes = new byte[7];
+ private static Key createDESKey(final byte[] bytes, final int offset) {
+ final byte[] keyBytes = new byte[7];
System.arraycopy(bytes, offset, keyBytes, 0, 7);
- byte[] material = new byte[8];
+ final byte[] material = new byte[8];
material[0] = keyBytes[0];
material[1] = (byte) (keyBytes[0] << 7 | (keyBytes[1] & 0xff) >>> 1);
material[2] = (byte) (keyBytes[1] << 6 | (keyBytes[2] & 0xff) >>> 2);
@@ -814,10 +793,10 @@ final class NTLMEngineImpl implements NTLMEngine {
* @param bytes
* The data whose parity bits are to be adjusted for odd parity.
*/
- private static void oddParity(byte[] bytes) {
+ private static void oddParity(final byte[] bytes) {
for (int i = 0; i < bytes.length; i++) {
- byte b = bytes[i];
- boolean needsParity = (((b >>> 7) ^ (b >>> 6) ^ (b >>> 5) ^ (b >>> 4) ^ (b >>> 3)
+ final byte b = bytes[i];
+ final boolean needsParity = (((b >>> 7) ^ (b >>> 6) ^ (b >>> 5) ^ (b >>> 4) ^ (b >>> 3)
^ (b >>> 2) ^ (b >>> 1)) & 0x01) == 0;
if (needsParity) {
bytes[i] |= (byte) 0x01;
@@ -840,7 +819,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Constructor to use when message contents are known */
- NTLMMessage(String messageBody, int expectedType) throws NTLMEngineException {
+ NTLMMessage(final String messageBody, final int expectedType) throws NTLMEngineException {
messageContents = Base64.decodeBase64(EncodingUtils.getBytes(messageBody,
DEFAULT_CHARSET));
// Look for NTLM message
@@ -855,7 +834,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
// Check to be sure there's a type 2 message indicator next
- int type = readULong(SIGNATURE.length);
+ final int type = readULong(SIGNATURE.length);
if (type != expectedType)
throw new NTLMEngineException("NTLM type " + Integer.toString(expectedType)
+ " message expected - instead got type " + Integer.toString(type));
@@ -877,43 +856,43 @@ final class NTLMEngineImpl implements NTLMEngine {
}
/** Read a byte from a position within the message buffer */
- protected byte readByte(int position) throws NTLMEngineException {
+ protected byte readByte(final int position) throws NTLMEngineException {
if (messageContents.length < position + 1)
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(byte[] buffer, int position) throws NTLMEngineException {
+ protected void readBytes(final byte[] buffer, final int position) throws NTLMEngineException {
if (messageContents.length < position + buffer.length)
throw new NTLMEngineException("NTLM: Message too short");
System.arraycopy(messageContents, position, buffer, 0, buffer.length);
}
/** Read a ushort from a position within the message buffer */
- protected int readUShort(int position) throws NTLMEngineException {
+ protected int readUShort(final int position) throws NTLMEngineException {
return NTLMEngineImpl.readUShort(messageContents, position);
}
/** Read a ulong from a position within the message buffer */
- protected int readULong(int position) throws NTLMEngineException {
+ protected int readULong(final int position) throws NTLMEngineException {
return NTLMEngineImpl.readULong(messageContents, position);
}
/** Read a security buffer from a position within the message buffer */
- protected byte[] readSecurityBuffer(int position) throws NTLMEngineException {
+ protected byte[] readSecurityBuffer(final int position) throws NTLMEngineException {
return NTLMEngineImpl.readSecurityBuffer(messageContents, position);
}
/**
* Prepares the object to create a response of the given length.
*
- * @param length
+ * @param maxlength
* the maximum length of the response to prepare, not
* including the type and the signature (which this method
* adds).
*/
- protected void prepareResponse(int maxlength, int messageType) {
+ protected void prepareResponse(final int maxlength, final int messageType) {
messageContents = new byte[maxlength];
currentOutputPosition = 0;
addBytes(SIGNATURE);
@@ -926,7 +905,7 @@ final class NTLMEngineImpl implements NTLMEngine {
* @param b
* the byte to add.
*/
- protected void addByte(byte b) {
+ protected void addByte(final byte b) {
messageContents[currentOutputPosition] = b;
currentOutputPosition++;
}
@@ -937,21 +916,21 @@ final class NTLMEngineImpl implements NTLMEngine {
* @param bytes
* the bytes to add.
*/
- protected void addBytes(byte[] bytes) {
- for (byte b : bytes) {
+ protected void addBytes(final byte[] bytes) {
+ for (final byte b : bytes) {
messageContents[currentOutputPosition] = b;
currentOutputPosition++;
}
}
/** Adds a USHORT to the response */
- protected void addUShort(int value) {
+ protected void addUShort(final int value) {
addByte((byte) (value & 0xff));
addByte((byte) (value >> 8 & 0xff));
}
/** Adds a ULong to the response */
- protected void addULong(int value) {
+ protected void addULong(final int value) {
addByte((byte) (value & 0xff));
addByte((byte) (value >> 8 & 0xff));
addByte((byte) (value >> 16 & 0xff));
@@ -965,12 +944,10 @@ final class NTLMEngineImpl implements NTLMEngine {
* @return The response as above.
*/
String getResponse() {
- byte[] resp;
+ final byte[] resp;
if (messageContents.length > currentOutputPosition) {
- byte[] tmp = new byte[currentOutputPosition];
- for (int i = 0; i < currentOutputPosition; i++) {
- tmp[i] = messageContents[i];
- }
+ final byte[] tmp = new byte[currentOutputPosition];
+ System.arraycopy(messageContents, 0, tmp, 0, currentOutputPosition);
resp = tmp;
} else {
resp = messageContents;
@@ -986,13 +963,13 @@ final class NTLMEngineImpl implements NTLMEngine {
protected byte[] domainBytes;
/** Constructor. Include the arguments the message will need */
- Type1Message(String domain, String host) throws NTLMEngineException {
+ Type1Message(final String domain, final String host) throws NTLMEngineException {
super();
try {
// Strip off domain name from the host!
- String unqualifiedHost = convertHost(host);
+ final String unqualifiedHost = convertHost(host);
// Use only the base domain name!
- String unqualifiedDomain = convertDomain(domain);
+ final String unqualifiedDomain = convertDomain(domain);
hostBytes = unqualifiedHost.getBytes("ASCII");
domainBytes = unqualifiedDomain.toUpperCase(Locale.US).getBytes("ASCII");
@@ -1009,7 +986,7 @@ final class NTLMEngineImpl implements NTLMEngine {
String getResponse() {
// Now, build the message. Calculate its length first, including
// signature or type.
- int finalLength = 32 + 8 /*+ hostBytes.length + domainBytes.length */;
+ final int finalLength = 32 + 8 /*+ hostBytes.length + domainBytes.length */;
// Set up the response. This will initialize the signature, message
// type, and flags.
@@ -1081,7 +1058,7 @@ final class NTLMEngineImpl implements NTLMEngine {
protected byte[] targetInfo;
protected int flags;
- Type2Message(String message) throws NTLMEngineException {
+ Type2Message(final String message) throws NTLMEngineException {
super(message, 2);
// Type 2 message is laid out as follows:
@@ -1115,7 +1092,7 @@ final class NTLMEngineImpl implements NTLMEngine {
// in Type2 messages, so use the length of the packet to decide
// how to proceed instead
if (getMessageLength() >= 12 + 8) {
- byte[] bytes = readSecurityBuffer(12);
+ final byte[] bytes = readSecurityBuffer(12);
if (bytes.length != 0) {
try {
target = new String(bytes, "UnicodeLittleUnmarked");
@@ -1129,7 +1106,7 @@ final class NTLMEngineImpl implements NTLMEngine {
targetInfo = null;
// TARGET_DESIRED flag cannot be relied on, so use packet length
if (getMessageLength() >= 40 + 8) {
- byte[] bytes = readSecurityBuffer(40);
+ final byte[] bytes = readSecurityBuffer(40);
if (bytes.length != 0) {
targetInfo = bytes;
}
@@ -1173,19 +1150,19 @@ final class NTLMEngineImpl implements NTLMEngine {
/** Constructor. Pass the arguments we will need */
- Type3Message(String domain, String host, String user, String password, byte[] nonce,
- int type2Flags, String target, byte[] targetInformation)
+ Type3Message(final String domain, final String host, final String user, final String password, final byte[] nonce,
+ final int type2Flags, final String target, final byte[] targetInformation)
throws NTLMEngineException {
// Save the flags
this.type2Flags = type2Flags;
// Strip off domain name from the host!
- String unqualifiedHost = convertHost(host);
+ final String unqualifiedHost = convertHost(host);
// Use only the base domain name!
- String unqualifiedDomain = convertDomain(domain);
+ final String unqualifiedDomain = convertDomain(domain);
// Create a cipher generator class. Use domain BEFORE it gets modified!
- CipherGen gen = new CipherGen(unqualifiedDomain, user, password, nonce, target, targetInformation);
+ final CipherGen gen = new CipherGen(unqualifiedDomain, user, password, nonce, target, targetInformation);
// Use the new code to calculate the responses, including v2 if that
// seems warranted.
@@ -1253,26 +1230,26 @@ final class NTLMEngineImpl implements NTLMEngine {
/** Assemble the response */
@Override
String getResponse() {
- int ntRespLen = ntResp.length;
- int lmRespLen = lmResp.length;
+ final int ntRespLen = ntResp.length;
+ final int lmRespLen = lmResp.length;
- int domainLen = domainBytes.length;
- int hostLen = hostBytes.length;
- int userLen = userBytes.length;
- int sessionKeyLen;
+ final int domainLen = domainBytes.length;
+ final int hostLen = hostBytes.length;
+ final int userLen = userBytes.length;
+ final int sessionKeyLen;
if (sessionKey != null)
sessionKeyLen = sessionKey.length;
else
sessionKeyLen = 0;
// Calculate the layout within the packet
- int lmRespOffset = 72; // allocate space for the version
- int ntRespOffset = lmRespOffset + lmRespLen;
- int domainOffset = ntRespOffset + ntRespLen;
- int userOffset = domainOffset + domainLen;
- int hostOffset = userOffset + userLen;
- int sessionKeyOffset = hostOffset + hostLen;
- int finalLength = sessionKeyOffset + sessionKeyLen;
+ final int lmRespOffset = 72; // allocate space for the version
+ final int ntRespOffset = lmRespOffset + lmRespLen;
+ final int domainOffset = ntRespOffset + ntRespLen;
+ final int userOffset = domainOffset + domainLen;
+ final int hostOffset = userOffset + userLen;
+ final int sessionKeyOffset = hostOffset + hostLen;
+ final int finalLength = sessionKeyOffset + sessionKeyLen;
// Start the response. Length includes signature and type
prepareResponse(finalLength, 3);
@@ -1367,26 +1344,26 @@ final class NTLMEngineImpl implements NTLMEngine {
}
}
- static void writeULong(byte[] buffer, int value, int offset) {
+ static void writeULong(final byte[] buffer, final int value, final int offset) {
buffer[offset] = (byte) (value & 0xff);
buffer[offset + 1] = (byte) (value >> 8 & 0xff);
buffer[offset + 2] = (byte) (value >> 16 & 0xff);
buffer[offset + 3] = (byte) (value >> 24 & 0xff);
}
- static int F(int x, int y, int z) {
+ static int F(final int x, final int y, final int z) {
return ((x & y) | (~x & z));
}
- static int G(int x, int y, int z) {
+ static int G(final int x, final int y, final int z) {
return ((x & y) | (x & z) | (y & z));
}
- static int H(int x, int y, int z) {
+ static int H(final int x, final int y, final int z) {
return (x ^ y ^ z);
}
- static int rotintlft(int val, int numbits) {
+ static int rotintlft(final int val, final int numbits) {
return ((val << numbits) | (val >>> (32 - numbits)));
}
@@ -1408,7 +1385,7 @@ final class NTLMEngineImpl implements NTLMEngine {
MD4() {
}
- void update(byte[] input) {
+ void update(final byte[] input) {
// We always deal with 512 bits at a time. Correspondingly, there is
// a buffer 64 bytes long that we write data into until it gets
// full.
@@ -1418,7 +1395,7 @@ final class NTLMEngineImpl implements NTLMEngine {
// We have enough data to do the next step. Do a partial copy
// and a transform, updating inputIndex and curBufferPos
// accordingly
- int transferAmt = dataBuffer.length - curBufferPos;
+ final int transferAmt = dataBuffer.length - curBufferPos;
System.arraycopy(input, inputIndex, dataBuffer, curBufferPos, transferAmt);
count += transferAmt;
curBufferPos = 0;
@@ -1429,7 +1406,7 @@ final class NTLMEngineImpl implements NTLMEngine {
// If there's anything left, copy it into the buffer and leave it.
// We know there's not enough left to process.
if (inputIndex < input.length) {
- int transferAmt = input.length - inputIndex;
+ final int transferAmt = input.length - inputIndex;
System.arraycopy(input, inputIndex, dataBuffer, curBufferPos, transferAmt);
count += transferAmt;
curBufferPos += transferAmt;
@@ -1439,9 +1416,9 @@ final class NTLMEngineImpl implements NTLMEngine {
byte[] getOutput() {
// Feed pad/length data into engine. This must round out the input
// to a multiple of 512 bits.
- int bufferIndex = (int) (count & 63L);
- int padLen = (bufferIndex < 56) ? (56 - bufferIndex) : (120 - bufferIndex);
- byte[] postBytes = new byte[padLen + 8];
+ final int bufferIndex = (int) (count & 63L);
+ final int padLen = (bufferIndex < 56) ? (56 - bufferIndex) : (120 - bufferIndex);
+ final byte[] postBytes = new byte[padLen + 8];
// Leading 0x80, specified amount of zero padding, then length in
// bits.
postBytes[0] = (byte) 0x80;
@@ -1454,7 +1431,7 @@ final class NTLMEngineImpl implements NTLMEngine {
update(postBytes);
// Calculate final result
- byte[] result = new byte[16];
+ final byte[] result = new byte[16];
writeULong(result, A, 0);
writeULong(result, B, 4);
writeULong(result, C, 8);
@@ -1464,7 +1441,7 @@ final class NTLMEngineImpl implements NTLMEngine {
protected void processBuffer() {
// Convert current buffer to 16 ulongs
- int[] d = new int[16];
+ final int[] d = new int[16];
for (int i = 0; i < 16; i++) {
d[i] = (dataBuffer[i * 4] & 0xff) + ((dataBuffer[i * 4 + 1] & 0xff) << 8)
@@ -1473,10 +1450,10 @@ final class NTLMEngineImpl implements NTLMEngine {
}
// Do a round of processing
- int AA = A;
- int BB = B;
- int CC = C;
- int DD = D;
+ final int AA = A;
+ final int BB = B;
+ final int CC = C;
+ final int DD = D;
round1(d);
round2(d);
round3(d);
@@ -1487,7 +1464,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
- protected void round1(int[] d) {
+ protected void round1(final int[] d) {
A = rotintlft((A + F(B, C, D) + d[0]), 3);
D = rotintlft((D + F(A, B, C) + d[1]), 7);
C = rotintlft((C + F(D, A, B) + d[2]), 11);
@@ -1509,7 +1486,7 @@ final class NTLMEngineImpl implements NTLMEngine {
B = rotintlft((B + F(C, D, A) + d[15]), 19);
}
- protected void round2(int[] d) {
+ protected void round2(final int[] d) {
A = rotintlft((A + G(B, C, D) + d[0] + 0x5a827999), 3);
D = rotintlft((D + G(A, B, C) + d[4] + 0x5a827999), 5);
C = rotintlft((C + G(D, A, B) + d[8] + 0x5a827999), 9);
@@ -1532,7 +1509,7 @@ final class NTLMEngineImpl implements NTLMEngine {
}
- protected void round3(int[] d) {
+ protected void round3(final int[] d) {
A = rotintlft((A + H(B, C, D) + d[0] + 0x6ed9eba1), 3);
D = rotintlft((D + H(A, B, C) + d[8] + 0x6ed9eba1), 9);
C = rotintlft((C + H(D, A, B) + d[4] + 0x6ed9eba1), 11);
@@ -1566,7 +1543,8 @@ final class NTLMEngineImpl implements NTLMEngine {
protected byte[] opad;
protected MessageDigest md5;
- HMACMD5(byte[] key) throws NTLMEngineException {
+ HMACMD5(final byte[] input) throws NTLMEngineException {
+ byte[] key = input;
try {
md5 = MessageDigest.getInstance("MD5");
} catch (Exception ex) {
@@ -1607,18 +1585,18 @@ final class NTLMEngineImpl implements NTLMEngine {
/** Grab the current digest. This is the "answer". */
byte[] getOutput() {
- byte[] digest = md5.digest();
+ final byte[] digest = md5.digest();
md5.update(opad);
return md5.digest(digest);
}
/** Update by adding a complete array */
- void update(byte[] input) {
+ void update(final byte[] input) {
md5.update(input);
}
/** Update the algorithm */
- void update(byte[] input, int offset, int length) {
+ void update(final byte[] input, final int offset, final int length) {
md5.update(input, offset, length);
}
@@ -1636,7 +1614,7 @@ final class NTLMEngineImpl implements NTLMEngine {
final String domain,
final String workstation,
final String challenge) throws NTLMEngineException {
- Type2Message t2m = new Type2Message(challenge);
+ final Type2Message t2m = new Type2Message(challenge);
return getType3Message(
username,
password,
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java
index 8c7145547..74dff36f1 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/AbstractAuthenticationHandler.java
@@ -46,7 +46,6 @@ import org.apache.http.auth.AuthSchemeRegistry;
import org.apache.http.auth.AuthenticationException;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.client.AuthenticationHandler;
-import org.apache.http.client.AuthenticationStrategy;
import org.apache.http.client.params.AuthPolicy;
import org.apache.http.client.protocol.ClientContext;
import org.apache.http.protocol.HTTP;
@@ -59,7 +58,7 @@ import org.apache.http.util.CharArrayBuffer;
*
* @since 4.0
*
- * @deprecated (4.2) use {@link AuthenticationStrategy}
+ * @deprecated (4.2) use {@link org.apache.http.client.AuthenticationStrategy}
*/
@Deprecated
@Immutable
@@ -84,7 +83,7 @@ public abstract class AbstractAuthenticationHandler implements AuthenticationHan
final Map* Please see the Javadoc for {@link #createHttpProcessor()} for the details of the interceptors * that are set up by default. @@ -166,11 +164,16 @@ public class DefaultHttpClient extends AbstractHttpClient { * Saves the default set of HttpParams in the provided parameter. * These are: *
null
* if they can still determine a route, for example
* to a default target or by inspecting the request.
@@ -740,17 +741,14 @@ public class DefaultRequestDirector implements RequestDirector {
*
* @throws HttpException in case of a problem
*/
- protected HttpRoute determineRoute(HttpHost target,
+ protected HttpRoute determineRoute(final HttpHost targetHost,
final HttpRequest request,
final HttpContext context)
throws HttpException {
-
- if (target == null) {
- target = (HttpHost) request.getParams().getParameter(
- ClientPNames.DEFAULT_HOST);
- }
- Asserts.notNull(target, "Target host");
- return this.routePlanner.determineRoute(target, request, context);
+ return this.routePlanner.determineRoute(
+ targetHost != null ? targetHost : (HttpHost) request.getParams()
+ .getParameter(ClientPNames.DEFAULT_HOST),
+ request, context);
}
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java
index 1aa9a0ae0..52f1303a4 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java
@@ -37,13 +37,12 @@ import org.apache.http.annotation.Immutable;
import org.apache.http.auth.AUTH;
import org.apache.http.auth.MalformedChallengeException;
import org.apache.http.auth.params.AuthPNames;
-import org.apache.http.client.AuthenticationHandler;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;
/**
- * Default {@link AuthenticationHandler} implementation for target host
- * authentication.
+ * Default {@link org.apache.http.client.AuthenticationHandler} implementation
+ * for target host authentication.
*
* @since 4.0
*
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java b/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java
index b9f8dfbe9..3156b4fb6 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java
@@ -32,7 +32,6 @@ import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -68,7 +67,8 @@ public class FutureRequestExecutionService implements Closeable {
* and if you have less connections than threads, the threads will just end up
* blocking on getting a connection from the pool.
* @param executorService
- * any executorService will do here. E.g. {@link Executors#newFixedThreadPool(int)}
+ * any executorService will do here. E.g.
+ * {@link java.util.concurrent.Executors#newFixedThreadPool(int)}
*/
public FutureRequestExecutionService(
final HttpClient httpclient,
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java b/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
index bbc15ecc4..c17756f41 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
@@ -48,7 +48,6 @@ import org.apache.http.client.BackoffManager;
import org.apache.http.client.ConnectionBackoffStrategy;
import org.apache.http.client.CookieStore;
import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpClient;
import org.apache.http.client.HttpRequestRetryHandler;
import org.apache.http.client.RedirectStrategy;
import org.apache.http.client.ServiceUnavailableRetryStrategy;
@@ -111,7 +110,7 @@ import org.apache.http.protocol.RequestUserAgent;
import org.apache.http.util.VersionInfo;
/**
- * {@link HttpClient} builder.
+ * {@link CloseableHttpClient} builder.
*
* The following system properties are taken into account by this class
* if the {@link #useSystemProperties()} method is called.
@@ -207,6 +206,11 @@ public class HttpClientBuilder {
return this;
}
+ public final HttpClientBuilder setSslcontext(final SSLContext sslcontext) {
+ this.sslcontext = sslcontext;
+ return this;
+ }
+
public final HttpClientBuilder setConnectionManager(
final HttpClientConnectionManager connManager) {
this.connManager = connManager;
@@ -412,6 +416,16 @@ public class HttpClientBuilder {
return this;
}
+ public final HttpClientBuilder disableCookieManagement() {
+ this.cookieManagementDisabled = true;
+ return this;
+ }
+
+ public final HttpClientBuilder disableAuthCaching() {
+ this.authCachingDisabled = true;
+ return this;
+ }
+
public final HttpClientBuilder useSystemProperties() {
systemProperties = true;
return this;
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/LaxRedirectStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/LaxRedirectStrategy.java
index 9c6a12dc2..c88d6840b 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/LaxRedirectStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/LaxRedirectStrategy.java
@@ -28,15 +28,15 @@
package org.apache.http.impl.client;
import org.apache.http.annotation.Immutable;
-import org.apache.http.client.RedirectStrategy;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpHead;
import org.apache.http.client.methods.HttpPost;
/**
- * Lax {@link RedirectStrategy} implementation that automatically redirects all HEAD, GET and POST
- * requests. This strategy relaxes restrictions on automatic redirection of POST methods imposed
- * by the HTTP specification.
+ * Lax {@link org.apache.http.client.RedirectStrategy} implementation
+ * that automatically redirects all HEAD, GET and POST requests.
+ * This strategy relaxes restrictions on automatic redirection of
+ * POST methods imposed by the HTTP specification.
*
* @since 4.2
*/
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/ProxyAuthenticationStrategy.java b/httpclient/src/main/java/org/apache/http/impl/client/ProxyAuthenticationStrategy.java
index 332970373..49e6e9122 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/ProxyAuthenticationStrategy.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/ProxyAuthenticationStrategy.java
@@ -32,11 +32,11 @@ import java.util.Collection;
import org.apache.http.HttpStatus;
import org.apache.http.annotation.Immutable;
import org.apache.http.auth.AUTH;
-import org.apache.http.client.AuthenticationStrategy;
import org.apache.http.client.config.RequestConfig;
/**
- * Default {@link AuthenticationStrategy} implementation for proxy host authentication.
+ * Default {@link org.apache.http.client.AuthenticationStrategy} implementation
+ * for proxy host authentication.
*
* @since 4.2
*/
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java b/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java
index 5315e8109..8ba975066 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/RedirectLocations.java
@@ -30,10 +30,9 @@ package org.apache.http.impl.client;
import org.apache.http.annotation.NotThreadSafe;
import org.apache.http.client.URICollection;
-import java.net.URI;
-
/**
- * This class represents a collection of {@link URI}s used as redirect locations.
+ * This class represents a collection of {@link java.net.URI}s used
+ * as redirect locations.
*
* @since 4.0
*/
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java b/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java
index 61dc6da70..fe3d1866a 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/StandardHttpRequestRetryHandler.java
@@ -33,12 +33,11 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.http.HttpRequest;
import org.apache.http.annotation.Immutable;
-import org.apache.http.client.HttpRequestRetryHandler;
/**
- * A {@link HttpRequestRetryHandler} which assumes that all requested
- * HTTP methods which should be idempotent according to RFC-2616 are
- * in fact idempotent and can be retried.
+ * {@link org.apache.http.client.HttpRequestRetryHandler} which assumes
+ * that all requested HTTP methods which should be idempotent according
+ * to RFC-2616 are in fact idempotent and can be retried.
*
* According to RFC-2616 section 9.1.2 the idempotent HTTP methods are:
* GET, HEAD, PUT, DELETE, OPTIONS, and TRACE
diff --git a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
index d78680bfd..0cde9191c 100644
--- a/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
+++ b/httpclient/src/main/java/org/apache/http/impl/client/SystemDefaultCredentialsProvider.java
@@ -48,7 +48,7 @@ import org.apache.http.util.Args;
@ThreadSafe
public class SystemDefaultCredentialsProvider implements CredentialsProvider {
- private static Mapnull
+ * {@link org.apache.http.message.BasicLineParser#INSTANCE} will be used.
* @param responseFactory HTTP response factory. If null
* {@link DefaultHttpResponseFactory#INSTANCE} will be used.
* @param constraints the message constraints. If null
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java
index 7fa362c19..9c4fc0fc3 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultProxyRoutePlanner.java
@@ -32,13 +32,12 @@ import org.apache.http.HttpHost;
import org.apache.http.HttpRequest;
import org.apache.http.annotation.Immutable;
import org.apache.http.conn.SchemePortResolver;
-import org.apache.http.conn.routing.HttpRoutePlanner;
import org.apache.http.protocol.HttpContext;
import org.apache.http.util.Args;
/**
- * Implementation of an {@link HttpRoutePlanner} that routes requests through
- * a default proxy.
+ * Implementation of an {@link org.apache.http.conn.routing.HttpRoutePlanner}
+ * that routes requests through a default proxy.
*
* @since 4.3
*/
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
index 43525f413..e0df6e6aa 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/DefaultRoutePlanner.java
@@ -73,7 +73,7 @@ public class DefaultRoutePlanner implements HttpRoutePlanner {
proxy = determineProxy(host, request, context);
}
- HttpHost target;
+ final HttpHost target;
if (host.getPort() <= 0) {
try {
target = new HttpHost(
diff --git a/httpclient/src/main/java/org/apache/http/impl/conn/HttpConnPool.java b/httpclient/src/main/java/org/apache/http/impl/conn/HttpConnPool.java
index b55a87420..75e4eac27 100644
--- a/httpclient/src/main/java/org/apache/http/impl/conn/HttpConnPool.java
+++ b/httpclient/src/main/java/org/apache/http/impl/conn/HttpConnPool.java
@@ -45,7 +45,7 @@ import org.apache.http.pool.ConnFactory;
@Deprecated
class HttpConnPool extends AbstractConnPoolidletime
*/
@Override
- public void closeIdleConnections(long idletime, final TimeUnit tunit) {
+ public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
Args.notNull(tunit, "Time unit");
- if (idletime < 0) {
- idletime = 0;
- }
+ final long t = idletime > 0 ? idletime : 0;
if (log.isDebugEnabled()) {
- log.debug("Closing connections idle longer than " + idletime + " " + tunit);
+ log.debug("Closing connections idle longer than " + t + " " + tunit);
}
// the latest time for which connections will be closed
- final long deadline = System.currentTimeMillis() - tunit.toMillis(idletime);
+ final long deadline = System.currentTimeMillis() - tunit.toMillis(t);
poolLock.lock();
try {
final Iteratortrue
iff the route is complete
*/
public final static boolean checkVia(final RouteTracker rt, final HttpRoute r,
- final HttpRouteDirector rd, int steps) {
+ final HttpRouteDirector rd, final int steps) {
final String msg = r.toString() + " @ " + rt.toString();
boolean complete = false;
- while (!complete && (steps > 0)) {
+ int n = steps;
+ while (!complete && (n > 0)) {
final int action = rd.nextStep(r, rt.toRoute());
switch (action) {
@@ -676,7 +677,7 @@ public class TestRouteTracker {
break;
} // switch
- steps--;
+ n--;
}
return complete;
diff --git a/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java b/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java
index a71ec2334..5fbbb524f 100644
--- a/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java
+++ b/httpclient/src/test/java/org/apache/http/conn/ssl/TestHostnameVerifier.java
@@ -310,8 +310,8 @@ public class TestHostnameVerifier {
@Test
// Check compressed IPv6 hostname matching
public void testHTTPCLIENT_1316() throws Exception{
- String cns[] = {"2001:0db8:aaaa:bbbb:cccc:0:0:0001"};
- String alt[] = {};
+ final String cns[] = {"2001:0db8:aaaa:bbbb:cccc:0:0:0001"};
+ final String alt[] = {};
final X509HostnameVerifier bhv = new BrowserCompatHostnameVerifier();
final X509HostnameVerifier shv = new StrictHostnameVerifier();
checkMatching(bhv, "2001:0db8:aaaa:bbbb:cccc:0:0:0001", cns, alt, false);
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 a2a90179c..f7de48c28 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
@@ -368,17 +368,12 @@ public class TestAbortHandling extends IntegrationTestBase {
}
public HttpClientConnection get(
- long timeout, final TimeUnit tunit)
- throws InterruptedException,
- ConnectionPoolTimeoutException {
+ final long timeout,
+ final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
connLatch.countDown(); // notify waiter that we're getting a connection
// zero usually means sleep forever, but CountDownLatch doesn't interpret it that way.
- if(timeout == 0) {
- timeout = Integer.MAX_VALUE;
- }
-
- if(!awaitLatch.await(timeout, tunit)) {
+ if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE, tunit)) {
throw new ConnectionPoolTimeoutException();
}
@@ -428,17 +423,12 @@ public class TestAbortHandling extends IntegrationTestBase {
}
public HttpClientConnection get(
- long timeout, final TimeUnit tunit)
- throws InterruptedException,
- ConnectionPoolTimeoutException {
+ final long timeout,
+ final TimeUnit tunit) throws InterruptedException, ConnectionPoolTimeoutException {
connLatch.countDown(); // notify waiter that we're getting a connection
// zero usually means sleep forever, but CountDownLatch doesn't interpret it that way.
- if(timeout == 0) {
- timeout = Integer.MAX_VALUE;
- }
-
- if(!awaitLatch.await(timeout, tunit)) {
+ if(!awaitLatch.await(timeout > 0 ? timeout : Integer.MAX_VALUE, tunit)) {
throw new ConnectionPoolTimeoutException();
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java
index 2ca11505b..3359b6a9a 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestClientRequestExecution.java
@@ -52,7 +52,6 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.message.BasicHttpRequest;
import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpCoreContext;
import org.apache.http.protocol.HttpRequestExecutor;
import org.apache.http.protocol.HttpRequestHandler;
import org.apache.http.util.EntityUtils;
diff --git a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java
index 96f406f0a..41f12b9a0 100644
--- a/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java
+++ b/httpclient/src/test/java/org/apache/http/impl/client/integration/TestContentCodings.java
@@ -41,13 +41,11 @@ import java.util.zip.GZIPOutputStream;
import org.apache.http.Header;
import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntity;
import org.apache.http.HttpException;
import org.apache.http.HttpRequest;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
-import org.apache.http.client.entity.DeflateDecompressingEntity;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.entity.InputStreamEntity;
import org.apache.http.entity.StringEntity;
@@ -107,7 +105,6 @@ public class TestContentCodings extends IntegrationTestBase {
* to return RFC1950 streams for deflate
content coding.
*
* @throws Exception
- * @see DeflateDecompressingEntity
*/
@Test
public void testDeflateSupportForServerReturningRfc1950Stream() throws Exception {
@@ -128,7 +125,6 @@ public class TestContentCodings extends IntegrationTestBase {
* to return RFC1951 streams for deflate
content coding.
*
* @throws Exception
- * @see DeflateDecompressingEntity
*/
@Test
public void testDeflateSupportForServerReturningRfc1951Stream() throws Exception {
@@ -216,12 +212,6 @@ public class TestContentCodings extends IntegrationTestBase {
}
}
- /**
- * Test that the returned {@link HttpEntity} in the response correctly overrides
- * {@link HttpEntity#writeTo(OutputStream)} for gzip-encoding.
- *
- * @throws Exception
- */
@Test
public void testHttpEntityWriteToForGzip() throws Exception {
final String entityText = "Hello, this is some plain text coming back.";
@@ -239,12 +229,6 @@ public class TestContentCodings extends IntegrationTestBase {
Assert.assertEquals(entityText, out.toString("utf-8"));
}
- /**
- * Test that the returned {@link HttpEntity} in the response correctly overrides
- * {@link HttpEntity#writeTo(OutputStream)} for deflate-encoding.
- *
- * @throws Exception
- */
@Test
public void testHttpEntityWriteToForDeflate() throws Exception {
final String entityText = "Hello, this is some plain text coming back.";
@@ -475,8 +459,7 @@ public class TestContentCodings extends IntegrationTestBase {
} finally {
endGate.countDown();
}
- } catch (final InterruptedException e) {
-
+ } catch (final InterruptedException ignore) {
}
}
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 75ba9a2c9..7c62f6ae6 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
@@ -248,7 +248,7 @@ public class TestRedirects extends IntegrationTestBase {
Assert.assertEquals(HttpStatus.SC_MULTIPLE_CHOICES, response.getStatusLine().getStatusCode());
Assert.assertEquals("/oldlocation/", reqWrapper.getRequestLine().getUri());
- URICollection redirects = context.getRedirectLocations();
+ final URICollection redirects = context.getRedirectLocations();
Assert.assertNull(redirects);
}
@@ -272,11 +272,11 @@ public class TestRedirects extends IntegrationTestBase {
Assert.assertEquals("/newlocation/", reqWrapper.getRequestLine().getUri());
Assert.assertEquals(target, host);
- URICollection redirects = context.getRedirectLocations();
+ final URICollection redirects = context.getRedirectLocations();
Assert.assertNotNull(redirects);
Assert.assertEquals(1, redirects.getCount());
- URI redirect = URIUtils.rewriteURI(new URI("/newlocation/"), target);
+ final URI redirect = URIUtils.rewriteURI(new URI("/newlocation/"), target);
Assert.assertTrue(redirects.contains(redirect));
}
@@ -641,7 +641,7 @@ public class TestRedirects extends IntegrationTestBase {
try {
this.httpclient.execute(target, httpget);
} catch (ClientProtocolException ex) {
- Throwable cause = ex.getCause();
+ final Throwable cause = ex.getCause();
Assert.assertTrue(cause instanceof HttpException);
throw ex;
}
diff --git a/httpclient/src/test/java/org/apache/http/impl/conn/TestManagedHttpClientConnectionFactory.java b/httpclient/src/test/java/org/apache/http/impl/conn/TestManagedHttpClientConnectionFactory.java
index f09c5bbe9..a4fbdf517 100644
--- a/httpclient/src/test/java/org/apache/http/impl/conn/TestManagedHttpClientConnectionFactory.java
+++ b/httpclient/src/test/java/org/apache/http/impl/conn/TestManagedHttpClientConnectionFactory.java
@@ -39,7 +39,7 @@ public class TestManagedHttpClientConnectionFactory {
validateDefault(ManagedHttpClientConnectionFactory.INSTANCE.create(ConnectionConfig.DEFAULT));
}
- private void validateDefault(ManagedHttpClientConnection managedHttpClientConnection) {
+ private void validateDefault(final ManagedHttpClientConnection managedHttpClientConnection) {
// Nothing really interesting to check here
Assert.assertNotNull(managedHttpClientConnection.getId());
}
diff --git a/httpclient/src/test/java/org/apache/http/mockup/SecureSocketFactoryMockup.java b/httpclient/src/test/java/org/apache/http/mockup/SecureSocketFactoryMockup.java
index 9e84ce334..34e0c8ce8 100644
--- a/httpclient/src/test/java/org/apache/http/mockup/SecureSocketFactoryMockup.java
+++ b/httpclient/src/test/java/org/apache/http/mockup/SecureSocketFactoryMockup.java
@@ -29,12 +29,11 @@ package org.apache.http.mockup;
import java.net.Socket;
-import org.apache.http.conn.scheme.LayeredSchemeSocketFactory;
import org.apache.http.conn.scheme.SchemeLayeredSocketFactory;
import org.apache.http.params.HttpParams;
/**
- * {@link LayeredSchemeSocketFactory} mockup implementation.
+ * {@link org.apache.http.conn.scheme.LayeredSchemeSocketFactory} mockup implementation.
*/
@Deprecated
public class SecureSocketFactoryMockup extends SocketFactoryMockup
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java
index 83b878e2b..88f8dd4cc 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/MultipartEntity.java
@@ -67,20 +67,14 @@ public class MultipartEntity implements HttpEntity {
* @param charset the character set to use, may be {@code null}, in which case {@link MIME#DEFAULT_CHARSET} - i.e. US-ASCII - is used.
*/
public MultipartEntity(
- HttpMultipartMode mode,
- String boundary,
+ final HttpMultipartMode mode,
+ final String boundary,
final Charset charset) {
super();
- if (boundary == null) {
- boundary = generateBoundary();
- }
- if (mode == null) {
- mode = HttpMultipartMode.STRICT;
- }
- this.multipart = new HttpMultipart("form-data", charset, boundary, mode);
- this.contentType = new BasicHeader(
- HTTP.CONTENT_TYPE,
- generateContentType(boundary, charset));
+ final String b = boundary != null ? boundary : generateBoundary();
+ final HttpMultipartMode m = mode != null ? mode : HttpMultipartMode.STRICT;
+ this.multipart = new HttpMultipart("form-data", charset, b, m);
+ this.contentType = new BasicHeader(HTTP.CONTENT_TYPE, generateContentType(b, charset));
this.dirty = true;
}
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java b/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
index ef95ecfae..cd90c9afd 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/ByteArrayBody.java
@@ -31,13 +31,12 @@ import java.io.OutputStream;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MIME;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.util.Args;
/**
* Binary body part backed by a byte array.
*
- * @see MultipartEntityBuilder
+ * @see org.apache.http.entity.mime.MultipartEntityBuilder
*
* @since 4.1
*/
@@ -61,7 +60,7 @@ public class ByteArrayBody extends AbstractContentBody {
* @param filename The name of the file contained in this part.
*
* @deprecated (4.3) use {@link ByteArrayBody#ByteArrayBody(byte[], ContentType, String)}
- * or {@link MultipartEntityBuilder}
+ * or {@link org.apache.http.entity.mime.MultipartEntityBuilder}
*/
@Deprecated
public ByteArrayBody(final byte[] data, final String mimeType, final String filename) {
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java b/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java
index d6dfac068..16c915e57 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/FileBody.java
@@ -35,13 +35,12 @@ import java.io.OutputStream;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MIME;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.util.Args;
/**
* Binary body part backed by a file.
*
- * @see MultipartEntityBuilder
+ * @see org.apache.http.entity.mime.MultipartEntityBuilder
*
* @since 4.0
*/
@@ -54,7 +53,7 @@ public class FileBody extends AbstractContentBody {
* @since 4.1
*
* @deprecated (4.3) use {@link FileBody#FileBody(File, ContentType, String)}
- * or {@link MultipartEntityBuilder}
+ * or {@link org.apache.http.entity.mime.MultipartEntityBuilder}
*/
@Deprecated
public FileBody(final File file,
@@ -68,7 +67,7 @@ public class FileBody extends AbstractContentBody {
* @since 4.1
*
* @deprecated (4.3) use {@link FileBody#FileBody(File, ContentType)}
- * or {@link MultipartEntityBuilder}
+ * or {@link org.apache.http.entity.mime.MultipartEntityBuilder}
*/
@Deprecated
public FileBody(final File file,
@@ -79,7 +78,7 @@ public class FileBody extends AbstractContentBody {
/**
* @deprecated (4.3) use {@link FileBody#FileBody(File, ContentType)}
- * or {@link MultipartEntityBuilder}
+ * or {@link org.apache.http.entity.mime.MultipartEntityBuilder}
*/
@Deprecated
public FileBody(final File file, final String mimeType) {
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java b/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java
index b4b9dd0cb..573aaa540 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/InputStreamBody.java
@@ -33,13 +33,12 @@ import java.io.OutputStream;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MIME;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.util.Args;
/**
* Binary body part backed by an input stream.
*
- * @see MultipartEntityBuilder
+ * @see org.apache.http.entity.mime.MultipartEntityBuilder
*
* @since 4.0
*/
@@ -52,7 +51,7 @@ public class InputStreamBody extends AbstractContentBody {
* @since 4.1
*
* @deprecated (4.3) use {@link InputStreamBody#InputStreamBody(InputStream, ContentType,
- * String)} or {@link MultipartEntityBuilder}
+ * String)} or {@link org.apache.http.entity.mime.MultipartEntityBuilder}
*/
@Deprecated
public InputStreamBody(final InputStream in, final String mimeType, final String filename) {
diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java b/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
index 44dbcf4da..d8d43119b 100644
--- a/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
+++ b/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
@@ -40,13 +40,12 @@ import java.nio.charset.UnsupportedCharsetException;
import org.apache.http.Consts;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.mime.MIME;
-import org.apache.http.entity.mime.MultipartEntityBuilder;
import org.apache.http.util.Args;
/**
* Text body part backed by a byte array.
*
- * @see MultipartEntityBuilder
+ * @see org.apache.http.entity.mime.MultipartEntityBuilder
*
* @since 4.0
*/
@@ -58,7 +57,7 @@ public class StringBody extends AbstractContentBody {
* @since 4.1
*
* @deprecated (4.3) use {@link StringBody#StringBody(String, ContentType)}
- * or {@link MultipartEntityBuilder}
+ * or {@link org.apache.http.entity.mime.MultipartEntityBuilder}
*/
@Deprecated
public static StringBody create(
@@ -76,7 +75,7 @@ public class StringBody extends AbstractContentBody {
* @since 4.1
*
* @deprecated (4.3) use {@link StringBody#StringBody(String, ContentType)}
- * or {@link MultipartEntityBuilder}
+ * or {@link org.apache.http.entity.mime.MultipartEntityBuilder}
*/
@Deprecated
public static StringBody create(
@@ -88,7 +87,7 @@ public class StringBody extends AbstractContentBody {
* @since 4.1
*
* @deprecated (4.3) use {@link StringBody#StringBody(String, ContentType)}
- * or {@link MultipartEntityBuilder}
+ * or {@link org.apache.http.entity.mime.MultipartEntityBuilder}
*/
@Deprecated
public static StringBody create(final String text) throws IllegalArgumentException {
@@ -105,7 +104,7 @@ public class StringBody extends AbstractContentBody {
* @throws IllegalArgumentException if the {@code text} parameter is null
*
* @deprecated (4.3) use {@link StringBody#StringBody(String, ContentType)}
- * or {@link MultipartEntityBuilder}
+ * or {@link org.apache.http.entity.mime.MultipartEntityBuilder}
*/
@Deprecated
public StringBody(
@@ -125,7 +124,7 @@ public class StringBody extends AbstractContentBody {
* @throws IllegalArgumentException if the {@code text} parameter is null
*
* @deprecated (4.3) use {@link StringBody#StringBody(String, ContentType)}
- * or {@link MultipartEntityBuilder}
+ * or {@link org.apache.http.entity.mime.MultipartEntityBuilder}
*/
@Deprecated
public StringBody(final String text, final Charset charset) throws UnsupportedEncodingException {
@@ -142,7 +141,7 @@ public class StringBody extends AbstractContentBody {
* @throws IllegalArgumentException if the {@code text} parameter is null
*
* @deprecated (4.3) use {@link StringBody#StringBody(String, ContentType)}
- * or {@link MultipartEntityBuilder}
+ * or {@link org.apache.http.entity.mime.MultipartEntityBuilder}
*/
@Deprecated
public StringBody(final String text) throws UnsupportedEncodingException {