diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HeaderConstants.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HeaderConstants.java index 1dbaaf33f..e2c6cdb77 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HeaderConstants.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HeaderConstants.java @@ -26,14 +26,11 @@ */ package org.apache.hc.client5.http.cache; -import org.apache.hc.core5.annotation.Contract; -import org.apache.hc.core5.annotation.ThreadingBehavior; - /** * Records static constants for various HTTP header names. + * * @since 4.1 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) public class HeaderConstants { public static final String GET_METHOD = "GET"; diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpAsyncCacheStorage.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpAsyncCacheStorage.java index 6fdf1f850..447af80d5 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpAsyncCacheStorage.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpAsyncCacheStorage.java @@ -29,6 +29,8 @@ package org.apache.hc.client5.http.cache; import java.util.Collection; import java.util.Map; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.concurrent.Cancellable; import org.apache.hc.core5.concurrent.FutureCallback; @@ -37,9 +39,13 @@ import org.apache.hc.core5.concurrent.FutureCallback; * storage backend that can then be plugged into the asynchronous * (non-blocking ) request execution * pipeline. + *
+ * Implementations of this interface are expected to be threading-safe. + *
* * @since 5.0 */ +@Contract(threading = ThreadingBehavior.SAFE) public interface HttpAsyncCacheStorage { /** diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpAsyncCacheStorageAdaptor.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpAsyncCacheStorageAdaptor.java index baa849768..7f1e525b3 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpAsyncCacheStorageAdaptor.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpAsyncCacheStorageAdaptor.java @@ -30,6 +30,8 @@ import java.util.Collection; import java.util.Map; import org.apache.hc.client5.http.impl.Operations; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.concurrent.Cancellable; import org.apache.hc.core5.concurrent.FutureCallback; import org.apache.hc.core5.util.Args; @@ -40,6 +42,7 @@ import org.apache.hc.core5.util.Args; * * @since 5.0 */ +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) public final class HttpAsyncCacheStorageAdaptor implements HttpAsyncCacheStorage { private final HttpCacheStorage cacheStorage; diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheCASOperation.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheCASOperation.java index 722b11689..4b59bb37f 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheCASOperation.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheCASOperation.java @@ -26,11 +26,15 @@ */ package org.apache.hc.client5.http.cache; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; + /** * Atomic Compare-And-Swap (CAS) cache operation. * * @since 5.0 */ +@Contract(threading = ThreadingBehavior.STATELESS) public interface HttpCacheCASOperation { /** diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheContext.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheContext.java index f1e4e8f32..435bc8618 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheContext.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheContext.java @@ -31,6 +31,9 @@ import org.apache.hc.core5.http.protocol.BasicHttpContext; import org.apache.hc.core5.http.protocol.HttpContext; /** + * Adaptor class that provides convenience type safe setters and getters + * for caching {@link HttpContext} attributes. + * * @since 4.3 */ public class HttpCacheContext extends HttpClientContext { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheEntrySerializer.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheEntrySerializer.java index 70f57c6bd..e08a08dfc 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheEntrySerializer.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheEntrySerializer.java @@ -26,11 +26,15 @@ */ package org.apache.hc.client5.http.cache; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; + /** * Serializer / deserializer for {@link HttpCacheStorageEntry} entries. * * @since 5.0 */ +@Contract(threading = ThreadingBehavior.STATELESS) public interface HttpCacheEntrySerializer+ * Implementations of this interface are expected to be threading-safe. + *
* * @since 4.1 */ +@Contract(threading = ThreadingBehavior.SAFE) public interface HttpCacheStorage { /** diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheStorageEntry.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheStorageEntry.java index 5e3cb7a20..1031d019a 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheStorageEntry.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/HttpCacheStorageEntry.java @@ -28,8 +28,16 @@ package org.apache.hc.client5.http.cache; import java.io.Serializable; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.util.Args; +/** + * This class contains a {@link HttpCacheEntry} along with its key. + * + * @since 5.0 + */ +@Contract(threading = ThreadingBehavior.IMMUTABLE) public final class HttpCacheStorageEntry implements Serializable { private static final long serialVersionUID = 1L; diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/Resource.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/Resource.java index 1a986e22f..b2cf02892 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/Resource.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/Resource.java @@ -30,12 +30,19 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; import java.io.Serializable; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; + /** * Represents a disposable system resource used for handling * cached response bodies. + *+ * Implementations of this interface are expected to be threading-safe. + *
* * @since 4.1 */ +@Contract(threading = ThreadingBehavior.SAFE) public abstract class Resource implements Serializable { private static final long serialVersionUID = 1L; diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/ResourceFactory.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/ResourceFactory.java index e94a82bbd..2ef204a6f 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/ResourceFactory.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/ResourceFactory.java @@ -26,12 +26,16 @@ */ package org.apache.hc.client5.http.cache; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; + /** * Generates {@link Resource} instances for handling cached * HTTP response bodies. * * @since 4.1 */ +@Contract(threading = ThreadingBehavior.STATELESS) public interface ResourceFactory { /** diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/package-info.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/package-info.java new file mode 100644 index 000000000..9e9b2a505 --- /dev/null +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/cache/package-info.java @@ -0,0 +1,32 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + *- This package consists largely of constants and interfaces that are - necessary for building new storage backends for the - {@link org.apache.hc.client5.http.impl.client.cache.CachingHttpClient} or for - those clients wanting to get a little more behavioral information - out of the cache module (for example, whether a particular response - was a cache hit or not). Developers that simply want to instantiate - and make use of the caching module will be better off looking at - the {@code CachingHttpClient} documentation itself. -
-- The classes in this package can be divided into two main groups: - reference constants and interfaces needed for storage backends. In - the former group, - {@link org.apache.hc.client5.http.client.cache.HeaderConstants} contains a list - of HTTP header names encoded as static fields, and the - {@link org.apache.hc.client5.http.client.cache.CacheResponseStatus} enumeration - values are set in an {@link org.apache.hc.client5.http.protocol.HttpContext} by - the {@code CachingHttpClient} to indicate how the request was - processed by the caching module itself. -
-- New storage backends will need to implement the - {@link org.apache.hc.client5.http.client.cache.HttpCacheStorage} - interface; they can then be passed to one of the {@code CachingHttpClient} - constructors, which will happily make use of the new storage mechanism. - The {@link org.apache.hc.client5.http.client.cache.HttpCacheEntry} class shows the - datastructure for a cache entry that must be stored by the - {@code HttpCacheStorage}. - There is, in addition, the notion of a - {@link org.apache.hc.client5.http.client.cache.Resource} and an associated - {@link org.apache.hc.client5.http.client.cache.ResourceFactory}, which are used for - managing the handling of cached response bodies. The default implementation - used by the {@code CachingHttpClient} stores response bodies in memory; - alternative implementations might involve storing these in a filesystem. A new - {@code ResourceFactory} can be provided along with a {@code HttpCacheStorage} - in one of the constructors to the {@code CachingHttpClient}. Finally, some - of the additional storage backends we provide, like the - {@link org.apache.hc.client5.http.impl.client.cache.ehcache.EhcacheHttpCacheStorage} and - {@link org.apache.hc.client5.http.impl.client.cache.memcached.MemcachedHttpCacheStorage}, - can be provided with different serializers for the cache entry metadata; - developers wanting to experiment with different serialization techniques - should implement the - {@link org.apache.hc.client5.http.client.cache.HttpCacheEntrySerializer} interface. -
- - diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java index 2cb66f1a8..beecb4dee 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/AsyncCachingExec.java @@ -88,7 +88,7 @@ import org.apache.hc.core5.util.ByteArrayBuffer; * @since 5.0 */ @Contract(threading = ThreadingBehavior.SAFE) // So long as the responseCache implementation is threadsafe -public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler { +class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler { private final HttpAsyncCache responseCache; private final DefaultAsyncCacheRevalidator cacheRevalidator; @@ -120,7 +120,7 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH this.conditionalRequestBuilder = conditionalRequestBuilder; } - public AsyncCachingExec( + AsyncCachingExec( final HttpAsyncCache cache, final ScheduledExecutorService executorService, final SchedulingStrategy schedulingStrategy, @@ -130,7 +130,7 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH config); } - public AsyncCachingExec( + AsyncCachingExec( final ResourceFactory resourceFactory, final HttpAsyncCacheStorage storage, final ScheduledExecutorService executorService, @@ -144,7 +144,7 @@ public class AsyncCachingExec extends CachingExecBase implements AsyncExecChainH final AsyncExecChain.Scope scope, final AsyncExecCallback asyncExecCallback) { scope.clientContext.setAttribute(HttpCoreContext.HTTP_RESPONSE, cacheResponse); - scope.execRuntime.releaseConnection(); + scope.execRuntime.releaseEndpoint(); final SimpleBody body = cacheResponse.getBody(); final byte[] content = body != null ? body.getBodyBytes() : null; diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicIdGenerator.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicIdGenerator.java index 5c48ed719..cfa28aca7 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicIdGenerator.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/BasicIdGenerator.java @@ -33,13 +33,9 @@ import java.security.SecureRandom; import java.util.Formatter; import java.util.Locale; -import org.apache.hc.core5.annotation.Contract; -import org.apache.hc.core5.annotation.ThreadingBehavior; - /** * Should produce reasonably unique tokens. */ -@Contract(threading = ThreadingBehavior.SAFE) class BasicIdGenerator { private final String hostname; diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ByteArrayCacheEntrySerializer.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ByteArrayCacheEntrySerializer.java index e5f653c75..7b7f45732 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ByteArrayCacheEntrySerializer.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/ByteArrayCacheEntrySerializer.java @@ -46,7 +46,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior; * * @since 4.1 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public final class ByteArrayCacheEntrySerializer implements HttpCacheEntrySerializer-This package contains a storage backend based on -Ehcache -that can be plugged into -a {@link org.apache.http.impl.client.cache.CachingHttpClient} and -used for storing cache entries. -
- - diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/KeyHashingScheme.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/KeyHashingScheme.java index d24faab08..a087b897b 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/KeyHashingScheme.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/KeyHashingScheme.java @@ -58,6 +58,8 @@ * 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 4.1 */ public interface KeyHashingScheme { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedKeyHashingException.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedKeyHashingException.java index 8b2fd1439..4499d9834 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedKeyHashingException.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedKeyHashingException.java @@ -27,9 +27,11 @@ package org.apache.hc.client5.http.impl.cache.memcached; /** - * Indicates a problem encountered when trying to map a + * Signals a problem encountered when trying to map a * logical "storage key" to a "cache key" suitable for use with * memcached. + * + * @since 4.1 */ public class MemcachedKeyHashingException extends RuntimeException { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedOperationTimeoutException.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedOperationTimeoutException.java index 054753cbe..d221d3ee1 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedOperationTimeoutException.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/MemcachedOperationTimeoutException.java @@ -29,9 +29,11 @@ package org.apache.hc.client5.http.impl.cache.memcached; import org.apache.hc.client5.http.cache.ResourceIOException; /** - * Raised when memcached times out on us. + * Signals memcached operation timeout. + * + * @since 4.1 */ -class MemcachedOperationTimeoutException extends ResourceIOException { +public class MemcachedOperationTimeoutException extends ResourceIOException { private static final long serialVersionUID = 1L; diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/PrefixKeyHashingScheme.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/PrefixKeyHashingScheme.java index b7a1fd41b..ad2dfe252 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/PrefixKeyHashingScheme.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/PrefixKeyHashingScheme.java @@ -32,6 +32,8 @@ package org.apache.hc.client5.http.impl.cache.memcached; * a known prefix to the results of another {@code KeyHashingScheme}. * Primarily useful for namespacing a shared memcached cluster, for * example. + * + * @since 4.1 */ public final class PrefixKeyHashingScheme implements KeyHashingScheme { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/SHA256KeyHashingScheme.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/SHA256KeyHashingScheme.java index dd23b3c42..c54938df4 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/SHA256KeyHashingScheme.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/SHA256KeyHashingScheme.java @@ -39,6 +39,8 @@ import org.slf4j.LoggerFactory; * algorithm. The hashes produced are hex-encoded SHA-256 * digests and hence are always 64-character hexadecimal * strings. + * + * @since 4.1 */ public final class SHA256KeyHashingScheme implements KeyHashingScheme { diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/package-info.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/package-info.java new file mode 100644 index 000000000..87618b2b8 --- /dev/null +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/memcached/package-info.java @@ -0,0 +1,32 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + *-This package contains a storage backend based on -memcached -that can be plugged into -a {@link org.apache.http.impl.client.cache.CachingHttpClient} and -used for storing cache entries. -
- - diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/package-info.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/package-info.java new file mode 100644 index 000000000..be63ef919 --- /dev/null +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/cache/package-info.java @@ -0,0 +1,32 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + *- This package contains a cache module that can be used for HTTP/1.1 - client-side caching. The primary classes in this package are the - {@link org.apache.hc.client5.http.impl.client.cache.CachingHttpClient}, - which is a drop-in replacement for - a {@link org.apache.hc.client5.http.impl.client.DefaultHttpClient} that adds - caching, and the {@link org.apache.hc.client5.http.impl.client.cache.CacheConfig} - class that can be used for configuring it. -
- - diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java index ee17f1fec..92e550931 100644 --- a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/ExponentialBackOffSchedulingStrategy.java @@ -52,9 +52,9 @@ import org.apache.hc.core5.util.TimeValue; * * The resulting delay won't exceed {@link #getMaxExpiry()}. * - * @since 4.3 + * @since 5.0 */ -@Contract(threading = ThreadingBehavior.SAFE) +@Contract(threading = ThreadingBehavior.STATELESS) public class ExponentialBackOffSchedulingStrategy implements SchedulingStrategy { public static final long DEFAULT_BACK_OFF_RATE = 10; diff --git a/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/package-info.java b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/package-info.java new file mode 100644 index 000000000..33186ec4b --- /dev/null +++ b/httpclient5-cache/src/main/java/org/apache/hc/client5/http/impl/schedule/package-info.java @@ -0,0 +1,31 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + *
* A connection pool with maximum 100 connections per route and
* a total maximum of 200 connections is used internally.
+ *
+ * @since 4.2
*/
public class Executor {
diff --git a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Form.java b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Form.java
index 1d578cae9..194b69eff 100644
--- a/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Form.java
+++ b/httpclient5-fluent/src/main/java/org/apache/hc/client5/http/fluent/Form.java
@@ -32,6 +32,11 @@ import java.util.List;
import org.apache.hc.core5.http.NameValuePair;
import org.apache.hc.core5.http.message.BasicNameValuePair;
+/**
+ * HTTP form used by the fluent facade.
+ *
+ * @since 4.2
+ */
public class Form {
private final List
- * EXPERIMENTAL
- *
* This will delegate negotiation to the windows machine.
*
- * EXPERIMENTAL
- *
- * EXPERIMENTAL
- *
+ * Implementations of this message are expected to perform resource deallocation
+ * allocated in the course of the request execution and response processing.
+ *
+ * Implementations of this message are expected to perform resource deallocation
+ * allocated in the course of the request execution and response processing.
+ *
* This interface is considered internal and generally ought not be used or accessed
* by custom request exec handlers.
+ *
* Authentication scheme are expected to transition through a series of standard phases or * states. + *
** Authentication scheme starts off its life cycle with no context and no specific state. + *
** The {@link #processChallenge(AuthChallenge, HttpContext)} method is called to * process an authentication challenge received either from the target server or a proxy. @@ -55,6 +58,7 @@ import org.apache.hc.core5.http.protocol.HttpContext; * challenge details. Standard authentication schemes are expected to provide a realm * attribute in the challenge. {@link #getRealm()} can be called to obtain an identifier * of the realm that requires authorization. + *
** Once the challenge has been fully processed the {@link #isResponseReady(HttpHost, * CredentialsProvider, HttpContext)} method to determine whether the scheme is capable of @@ -62,15 +66,18 @@ import org.apache.hc.core5.http.protocol.HttpContext; * required to do so. If this method returns {@code false} the authentication is considered * to be in FAILED state and no authorization response. Otherwise the scheme is considered * to be in RESPONSE_READY state. + *
** Once the scheme is ready to respond to the challenge the {@link #generateAuthResponse( * HttpHost, HttpRequest, HttpContext)} method to generate a response token, which will * be sent to the opposite endpoint in the subsequent request message. + *
** Certain non-standard schemes may involve multiple challenge / response exchanges to * fully establish a shared context and complete the authentication process. Authentication * schemes are required to return {@code true} {@link #isChallengeComplete()} once the * handshake is considered complete. + *
** The authentication scheme is considered successfully completed and in SUCCESS state * if the opposite endpoint accepts the request message containing the authorization @@ -78,6 +85,7 @@ import org.apache.hc.core5.http.protocol.HttpContext; * If the opposite endpoint sends status code 401 or 407 in response to a request message * containing the terminal authorization response, the scheme is considered unsuccessful * and in FAILED state. + *
* * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java index 2bc4a29e6..46fb78717 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthScope.java @@ -38,7 +38,7 @@ import org.apache.hc.core5.util.LangUtils; * {@code AuthScope} represents an authentication scope consisting of * an application protocol, a host name, a port number, a realm name * and an authentication scheme name. - * + * * @since 4.0 */ @Contract(threading = ThreadingBehavior.IMMUTABLE) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthStateCacheable.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthStateCacheable.java index 60435cdad..1c1cb8f6a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthStateCacheable.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthStateCacheable.java @@ -32,6 +32,12 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +/** + * Indicates that the state of an {@link AuthScheme} can be cached + * and re-used for preemptive authentication by subsequent requests. + * + * @since 5.0 + */ @Documented @Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthenticationException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthenticationException.java index 80d208a71..9fa3d6eb2 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthenticationException.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/AuthenticationException.java @@ -31,7 +31,6 @@ import org.apache.hc.core5.http.ProtocolException; /** * Signals a failure in authentication process * - * * @since 4.0 */ public class AuthenticationException extends ProtocolException { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java index b062675ea..66bac25a5 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/BasicUserPrincipal.java @@ -35,7 +35,7 @@ import org.apache.hc.core5.util.Args; import org.apache.hc.core5.util.LangUtils; /** - * Basic user principal used for HTTP authentication + * Basic username based principal representation. * * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsProvider.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsProvider.java index 13a595b5f..103fc060f 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsProvider.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsProvider.java @@ -34,6 +34,7 @@ import org.apache.hc.core5.http.protocol.HttpContext; * Implementations of this interface must be thread-safe. Access to shared * data must be synchronized as methods of this interface may be executed * from multiple threads. + * * * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsStore.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsStore.java index 49d1e3b98..a7578830e 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsStore.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/CredentialsStore.java @@ -32,6 +32,7 @@ package org.apache.hc.client5.http.auth; * Implementations of this interface must be thread-safe. Access to shared * data must be synchronized as methods of this interface may be executed * from multiple threads. + * * * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/InvalidCredentialsException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/InvalidCredentialsException.java index 74631a531..530a3e64a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/InvalidCredentialsException.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/InvalidCredentialsException.java @@ -26,17 +26,12 @@ */ package org.apache.hc.client5.http.auth; -import org.apache.hc.core5.annotation.Contract; -import org.apache.hc.core5.annotation.ThreadingBehavior; - /** * Authentication credentials required to respond to a authentication * challenge are invalid * - * * @since 4.0 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) public class InvalidCredentialsException extends AuthenticationException { private static final long serialVersionUID = -4834003835215460648L; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/KerberosCredentials.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/KerberosCredentials.java index fc49bcb34..e40963b2a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/KerberosCredentials.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/KerberosCredentials.java @@ -34,7 +34,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior; import org.ietf.jgss.GSSCredential; /** - * {@link Credentials} implementation based on GSSCredential for Kerberos Authentication. + * Kerberos specific {@link Credentials} representation based on {@link GSSCredential}. * * @since 4.4 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/MalformedChallengeException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/MalformedChallengeException.java index d2ba02e9d..de3590c02 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/MalformedChallengeException.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/MalformedChallengeException.java @@ -32,7 +32,6 @@ import org.apache.hc.core5.http.ProtocolException; * Signals that authentication challenge is in some way invalid or * illegal in the given context * - * * @since 4.0 */ public class MalformedChallengeException extends ProtocolException { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java index 7c56c80ad..1ee470d80 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/NTCredentials.java @@ -36,7 +36,7 @@ import org.apache.hc.core5.util.Args; import org.apache.hc.core5.util.LangUtils; /** - * {@link Credentials} implementation for Microsoft Windows platforms that includes + * Microsoft Windows specific {@link Credentials} representation that includes * Windows specific attributes such as name of the domain the user belongs to. * * @since 4.0 diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/UsernamePasswordCredentials.java b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/UsernamePasswordCredentials.java index ca49b694c..46b22cc0d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/auth/UsernamePasswordCredentials.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/auth/UsernamePasswordCredentials.java @@ -35,7 +35,7 @@ import org.apache.hc.core5.util.Args; import org.apache.hc.core5.util.LangUtils; /** - * Simple {@link Credentials} implementation based on a user name / password + * Simple {@link Credentials} representation based on a user name / password * pair. * * @since 4.0 diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/BackoffManager.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/BackoffManager.java index 2e4b8bf9f..48ca4f5c7 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/BackoffManager.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/BackoffManager.java @@ -34,7 +34,6 @@ import org.apache.hc.client5.http.HttpRoute; * using the connections. * * @since 4.2 - * */ public interface BackoffManager { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChain.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChain.java index fd1e92e27..d79c14b94 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChain.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChain.java @@ -31,11 +31,19 @@ import java.io.IOException; import org.apache.hc.client5.http.HttpRoute; import org.apache.hc.client5.http.protocol.HttpClientContext; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.util.Args; +/** + * Represents a single element in the client side classic request execution chain. + * + * @since 5.0 + */ +@Contract(threading = ThreadingBehavior.STATELESS) public interface ExecChain { final class Scope { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChainHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChainHandler.java index b4f1a6163..035c1000d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChainHandler.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecChainHandler.java @@ -29,14 +29,17 @@ package org.apache.hc.client5.http.classic; import java.io.IOException; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.http.ClassicHttpRequest; import org.apache.hc.core5.http.ClassicHttpResponse; import org.apache.hc.core5.http.HttpException; /** - * This interface represents an element in the HTTP request execution chain. Each element can - * either be a decorator around another element that implements a cross cutting aspect or - * a self-contained executor capable of producing a response for the given request. + * Abstract request execution handler in a classic client side request execution chain. + * Handlers can either be a decorator around another element that implements a cross + * cutting aspect or a self-contained executor capable of producing a response + * for the given request. ** Important: please note it is required for decorators that implement post execution aspects * or response post-processing of any sort to release resources associated with the response @@ -46,8 +49,18 @@ import org.apache.hc.core5.http.HttpException; * * @since 4.3 */ +@Contract(threading = ThreadingBehavior.STATELESS) public interface ExecChainHandler { + /** + * Executes the actual HTTP request. The handler can choose to return + * a response message or delegate request execution to the next element + * in the execution chain. + * + * @param request the actual request. + * @param scope the execution scope . + * @param chain the next element in the request execution chain. + */ ClassicHttpResponse execute( ClassicHttpRequest request, ExecChain.Scope scope, diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecRuntime.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecRuntime.java index bbefe28fb..734197a41 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecRuntime.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/ExecRuntime.java @@ -50,37 +50,110 @@ import org.apache.hc.core5.util.TimeValue; @Internal public interface ExecRuntime { + /** + * Determines of the request execution has been aborted. + * + * @return {@code true} if the request execution has been acquired, + * {@code false} otherwise. + */ boolean isExecutionAborted(); - boolean isConnectionAcquired(); + /** + * Determines of a connection endpoint has been acquired. + * + * @return {@code true} if an endpoint has been acquired, {@code false} otherwise. + */ + boolean isEndpointAcquired(); - void acquireConnection( + /** + * Acquires a connection endpoint. Endpoints can leased from a pool + * or unconnected new endpoint can be created. + * + * @param route the connection route. + * @param state the expected connection state. May be {@code null} if connection + * can be state-less or its state is irrelevant. + * @param context the execution context. + */ + void acquireEndpoint( HttpRoute route, Object state, HttpClientContext context) throws IOException; - void releaseConnection(); + /** + * Releases the acquired endpoint potentially making it available for re-use. + */ + void releaseEndpoint(); - void discardConnection(); + /** + * Shuts down and discards the acquired endpoint. + */ + void discardEndpoint(); - boolean isConnected(); + /** + * Determines of there the endpoint is connected to the initial hop (connection + * target in case of a direct route or to the first proxy hop in case of a route + * via a proxy or multiple proxies). + * + * @return {@code true} if the endpoint is connected, {@code false} otherwise. + */ + boolean isEndpointConnected(); - void disconnect() throws IOException; + /** + * Disconnects the local endpoint from the initial hop in the connection route. + */ + void disconnectEndpoint() throws IOException; - void connect(HttpClientContext context) throws IOException; + /** + * Connect the local endpoint to the initial hop (connection target in case + * of a direct route or to the first proxy hop in case of a route via a proxy + * or multiple proxies). + * + * @param context the execution context. + */ + void connectEndpoint(HttpClientContext context) throws IOException; + /** + * Upgrades transport security of the active connection by using the TLS security protocol. + * + * @param context the execution context. + */ void upgradeTls(HttpClientContext context) throws IOException; + /** + * Executes HTTP request using the given context. + * + * @param request the request message. + * @param context the execution context. + */ ClassicHttpResponse execute( ClassicHttpRequest request, HttpClientContext context) throws IOException, HttpException; + /** + * Determines of the connection is considered re-usable. + * + * @return {@code true} if the connection is re-usable, {@code false} otherwise. + */ boolean isConnectionReusable(); - void markConnectionReusable(Object state, TimeValue duration); + /** + * Marks the connection as potentially re-usable for the given period of time + * and also marks it as stateful if the state representation is given. + * @param state the connection state representation or {@code null} if stateless. + * @param validityTime the period of time this connection is valid for. + */ + void markConnectionReusable(Object state, TimeValue validityTime); + /** + * Marks the connection as non re-usable. + */ void markConnectionNonReusable(); + /** + * Forks this runtime for parallel execution. + * + * @return another runtime with the same configuration. + */ ExecRuntime fork(CancellableDependency cancellableAware); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/HttpClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/HttpClient.java index a63818b4f..7dcda6565 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/HttpClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/HttpClient.java @@ -126,12 +126,12 @@ public interface HttpClient { *
* * @param request the request to execute - * @param HttpClientResponseHandler the response handler + * @param responseHandler the response handler * * @return the response object as generated by the response handler. * @throws IOException in case of a problem or the connection was aborted */ -- * The HTTP DELETE method is defined in section 9.7 of - * RFC2616: - *
- * The DELETE method requests that the origin server delete the resource - * identified by the Request-URI. [...] The client cannot - * be guaranteed that the operation has been carried out, even if the - * status code returned from the origin server indicates that the action - * has been completed successfully. - *+ * HTTP DELETE method. * * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpGet.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpGet.java index e3e469349..8c30166c9 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpGet.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpGet.java @@ -31,17 +31,6 @@ import java.net.URI; /** * HTTP GET method. - *
- * The HTTP GET method is defined in section 9.3 of - * RFC2616: - *
- *- * The GET method means retrieve whatever information (in the form of an - * entity) is identified by the Request-URI. If the Request-URI refers - * to a data-producing process, it is the produced data which shall be - * returned as the entity in the response and not the source text of the - * process, unless that text happens to be the output of the process. - ** * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpHead.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpHead.java index 5fb140de3..c18835fd5 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpHead.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpHead.java @@ -31,20 +31,6 @@ import java.net.URI; /** * HTTP HEAD method. - *
- * The HTTP HEAD method is defined in section 9.4 of - * RFC2616: - *
- *- * The HEAD method is identical to GET except that the server MUST NOT - * return a message-body in the response. The metainformation contained - * in the HTTP headers in response to a HEAD request SHOULD be identical - * to the information sent in response to a GET request. This method can - * be used for obtaining metainformation about the entity implied by the - * request without transferring the entity-body itself. This method is - * often used for testing hypertext links for validity, accessibility, - * and recent modification. - ** * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpOptions.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpOptions.java index ca1241261..7a1e41b6b 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpOptions.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpOptions.java @@ -39,18 +39,6 @@ import org.apache.hc.core5.util.Args; /** * HTTP OPTIONS method. - *
- * The HTTP OPTIONS method is defined in section 9.2 of - * RFC2616: - *
- *- * The OPTIONS method represents a request for information about the - * communication options available on the request/response chain - * identified by the Request-URI. This method allows the client to - * determine the options and/or requirements associated with a resource, - * or the capabilities of a server, without implying a resource action - * or initiating a resource retrieval. - ** * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPatch.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPatch.java index 99c50c4f7..c1ee0fc2a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPatch.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPatch.java @@ -31,20 +31,6 @@ import java.net.URI; /** * HTTP PATCH method. - *
- * The HTTP PATCH method is defined in RF5789: - *
- *The PATCH - * method requests that a set of changes described in the request entity be - * applied to the resource identified by the Request- URI. Differs from the PUT - * method in the way the server processes the enclosed entity to modify the - * resource identified by the Request-URI. In a PUT request, the enclosed entity - * origin server, and the client is requesting that the stored version be - * replaced. With PATCH, however, the enclosed entity contains a set of - * instructions describing how a resource currently residing on the origin - * server should be modified to produce a new version. - ** * @since 4.2 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPost.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPost.java index fd102a34e..41c14531f 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPost.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPost.java @@ -31,24 +31,6 @@ import java.net.URI; /** * HTTP POST method. - *
- * The HTTP POST method is defined in section 9.5 of - * RFC2616: - *
- *- * The POST method is used to request that the origin server accept the entity - * enclosed in the request as a new subordinate of the resource identified by - * the Request-URI in the Request-Line. POST is designed to allow a uniform - * method to cover the following functions: - ** * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPut.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPut.java index fabe2b22e..68e70b3ba 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPut.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpPut.java @@ -31,16 +31,6 @@ import java.net.URI; /** * HTTP PUT method. - *- *
- *- Annotation of existing resources
- *- Posting a message to a bulletin board, newsgroup, mailing list, or - * similar group of articles
- *- Providing a block of data, such as the result of submitting a form, - * to a data-handling process
- *- Extending a database through an append operation
- *
- * The HTTP PUT method is defined in section 9.6 of - * RFC2616: - *
- *- * The PUT method requests that the enclosed entity be stored under the - * supplied Request-URI. If the Request-URI refers to an already - * existing resource, the enclosed entity SHOULD be considered as a - * modified version of the one residing on the origin server. - ** * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpTrace.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpTrace.java index 8bd12931f..17092a129 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpTrace.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/HttpTrace.java @@ -31,19 +31,6 @@ import java.net.URI; /** * HTTP TRACE method. - *
- * The HTTP TRACE method is defined in section 9.6 of - * RFC2616: - *
- *- * The TRACE method is used to invoke a remote, application-layer loop- - * back of the request message. The final recipient of the request - * SHOULD reflect the message received back to the client as the - * entity-body of a 200 (OK) response. The final recipient is either the - * origin server or the first proxy or gateway to receive a Max-Forwards - * value of zero (0) in the request (see section 14.31). A TRACE request - * MUST NOT include an entity. - ** * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/RequestBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/RequestBuilder.java index 4264be15d..1c330ea12 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/RequestBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/RequestBuilder.java @@ -60,9 +60,10 @@ import org.apache.hc.core5.util.Args; *
* Please note that this class treats parameters differently depending on composition * of the request: if the request has a content entity explicitly set with - * {@link #setEntity(org.apache.hc.core5.http.HttpEntity)} or it is not an entity enclosing method - * (such as POST or PUT), parameters will be added to the query component of the request URI. - * Otherwise, parameters will be added as a URL encoded {@link UrlEncodedFormEntity entity}. + * {@link #setEntity(org.apache.hc.core5.http.HttpEntity)} or it is not an entity enclosing + * method (such as POST or PUT), parameters will be added to the query component + * of the request URI. Otherwise, parameters will be added as a URL encoded + * {@link UrlEncodedFormEntity entity}. *
* * @since 4.3 diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/package-info.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/package-info.java index e0c25d2d3..b110daed1 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/package-info.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/methods/package-info.java @@ -26,6 +26,6 @@ */ /** - * Standard HTTP method implementations. + * Common HTTP methods and message handlers for the classic I/O model. */ package org.apache.hc.client5.http.classic.methods; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/package-info.java b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/package-info.java index 53fc06904..c7207cd1b 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/classic/package-info.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/classic/package-info.java @@ -26,6 +26,6 @@ */ /** - * Client HTTP communication APIs. + * HTTP client APIs based on the classic (blocking) I/O model. */ package org.apache.hc.client5.http.classic; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/config/package-info.java b/httpclient5/src/main/java/org/apache/hc/client5/http/config/package-info.java index 32e6e19a2..4c6896f84 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/config/package-info.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/config/package-info.java @@ -26,6 +26,6 @@ */ /** - * Client configuration APIs. + * HTTP client configuration APIs. */ package org.apache.hc.client5.http.config; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/BasicCookieStore.java b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/BasicCookieStore.java index 6e1cea44c..a3d6e2b96 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/BasicCookieStore.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/BasicCookieStore.java @@ -43,7 +43,6 @@ import org.apache.hc.core5.annotation.ThreadingBehavior; /** * Default implementation of {@link CookieStore} * - * * @since 4.0 */ @Contract(threading = ThreadingBehavior.SAFE) diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/Cookie.java b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/Cookie.java index 677af5c88..4a8ac10c7 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/Cookie.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/Cookie.java @@ -34,9 +34,6 @@ import java.util.Date; * (also referred to as "magic-cookie") that the HTTP agent and the target * server can exchange to maintain a session. In its simples form an HTTP * cookie is merely a name / value pair. - *- * Please do not use attributes marked as @Obsolete. They have been rendered - * obsolete by RFC 6265. * * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieAttributeHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieAttributeHandler.java index 676d71c3f..b19e8472d 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieAttributeHandler.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieAttributeHandler.java @@ -26,18 +26,22 @@ */ package org.apache.hc.client5.http.cookie; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; + /** * This interface represents a cookie attribute handler responsible * for parsing, validating, and matching a specific cookie attribute, * such as path, domain, port, etc. - * + *
* Different cookie specifications can provide a specific * implementation for this class based on their cookie handling * rules. - * + *
* * @since 4.0 */ +@Contract(threading = ThreadingBehavior.STATELESS) public interface CookieAttributeHandler { /** diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieIdentityComparator.java b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieIdentityComparator.java index fb17ec14e..098788a15 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieIdentityComparator.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieIdentityComparator.java @@ -36,12 +36,13 @@ import org.apache.hc.core5.annotation.ThreadingBehavior; /** * This cookie comparator can be used to compare identity of cookies. *- * Cookies are considered identical if their names are equal and - * their domain attributes match ignoring case. + * Cookies are considered identical if their names are equal and + * their domain attributes match ignoring case. + *
* * @since 4.0 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public class CookieIdentityComparator implements Serializable, Comparator- * Please do not use methods marked as @Obsolete. They have been rendered - * obsolete by RFC 6265. * * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieSpecProvider.java b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieSpecProvider.java index f6ddc47a5..55a3f5807 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieSpecProvider.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/CookieSpecProvider.java @@ -27,6 +27,8 @@ package org.apache.hc.client5.http.cookie; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.http.protocol.HttpContext; /** @@ -34,6 +36,7 @@ import org.apache.hc.core5.http.protocol.HttpContext; * * @since 4.3 */ +@Contract(threading = ThreadingBehavior.STATELESS) public interface CookieSpecProvider { /** diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/MalformedCookieException.java b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/MalformedCookieException.java index a24768abf..ddca9329b 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/MalformedCookieException.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/MalformedCookieException.java @@ -33,7 +33,6 @@ import org.apache.hc.core5.http.ProtocolException; * Signals that a cookie is in some way invalid or illegal in a given * context * - * * @since 4.0 */ public class MalformedCookieException extends ProtocolException { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/SetCookie.java b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/SetCookie.java index 72da3766d..620006aae 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/SetCookie.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/cookie/SetCookie.java @@ -32,9 +32,6 @@ import java.util.Date; /** * This interface represents a {@code Set-Cookie} response header sent by the * origin server to the HTTP agent in order to maintain a conversational state. - *
- * Please do not use methods marked as @Obsolete. They have been rendered - * obsolete by RFC 6265 * * @since 4.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DeflateInputStreamFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DeflateInputStreamFactory.java index 3fa666ae3..8ddefe8c9 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DeflateInputStreamFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/DeflateInputStreamFactory.java @@ -38,7 +38,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior; * * @since 5.0 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public class DeflateInputStreamFactory implements InputStreamFactory { /** diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/GZIPInputStreamFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/GZIPInputStreamFactory.java index 37bf6f748..6f599ce43 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/entity/GZIPInputStreamFactory.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/entity/GZIPInputStreamFactory.java @@ -39,7 +39,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior; * * @since 5.0 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public class GZIPInputStreamFactory implements InputStreamFactory { /** diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/AuthSupport.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/AuthSupport.java index 67d3b3536..823e600d3 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/AuthSupport.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/AuthSupport.java @@ -32,14 +32,18 @@ import org.apache.hc.client5.http.auth.AuthScope; import org.apache.hc.client5.http.auth.CredentialsStore; import org.apache.hc.client5.http.auth.UsernamePasswordCredentials; import org.apache.hc.client5.http.auth.AuthSchemes; +import org.apache.hc.core5.annotation.Internal; import org.apache.hc.core5.http.HttpHost; import org.apache.hc.core5.http.HttpRequest; import org.apache.hc.core5.net.URIAuthority; import org.apache.hc.core5.util.Args; /** + * Authentication support methods. + * * @since 5.0 */ +@Internal public class AuthSupport { public static void extractFromAuthority( diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ChainElements.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ChainElements.java index 99d252378..9dd95cdad 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ChainElements.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ChainElements.java @@ -27,6 +27,11 @@ package org.apache.hc.client5.http.impl; +/** + * Supported elements of request execution pipeline. + * + * @since 5.0 + */ public enum ChainElements { REDIRECT, BACK_OFF, RETRY_SERVICE_UNAVAILABLE, RETRY_IO_ERROR, CACHING, PROTOCOL, CONNECT, MAIN_TRANSPORT diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ConnPoolSupport.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ConnPoolSupport.java index a7d0da8ee..6cc87e47a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ConnPoolSupport.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ConnPoolSupport.java @@ -32,6 +32,11 @@ import org.apache.hc.core5.pool.ConnPoolControl; import org.apache.hc.core5.pool.PoolStats; import org.apache.hc.core5.util.Identifiable; +/** + * Connection pooling support methods. + * + * @since 5.0 + */ @Internal public final class ConnPoolSupport { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/CookieSpecRegistries.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/CookieSpecSupport.java similarity index 94% rename from httpclient5/src/main/java/org/apache/hc/client5/http/impl/CookieSpecRegistries.java rename to httpclient5/src/main/java/org/apache/hc/client5/http/impl/CookieSpecSupport.java index 5d1063e79..0bfe92c60 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/CookieSpecRegistries.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/CookieSpecSupport.java @@ -33,13 +33,17 @@ import org.apache.hc.client5.http.impl.cookie.IgnoreSpecProvider; import org.apache.hc.client5.http.impl.cookie.RFC6265CookieSpecProvider; import org.apache.hc.client5.http.psl.PublicSuffixMatcher; import org.apache.hc.client5.http.psl.PublicSuffixMatcherLoader; +import org.apache.hc.core5.annotation.Internal; import org.apache.hc.core5.http.config.Lookup; import org.apache.hc.core5.http.config.RegistryBuilder; /** - * @since 4.5 + * Cookie support methods. + * + * @since 5.0 */ -public final class CookieSpecRegistries { +@Internal +public final class CookieSpecSupport { /** * Creates a builder containing the default registry entries, using the provided public suffix matcher. @@ -74,6 +78,6 @@ public final class CookieSpecRegistries { return createDefaultBuilder(publicSuffixMatcher).build(); } - private CookieSpecRegistries() {} + private CookieSpecSupport() {} } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultAuthenticationStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultAuthenticationStrategy.java index 73ad51c23..a5578a30f 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultAuthenticationStrategy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultAuthenticationStrategy.java @@ -39,8 +39,8 @@ import org.apache.hc.client5.http.AuthenticationStrategy; import org.apache.hc.client5.http.auth.AuthChallenge; import org.apache.hc.client5.http.auth.AuthScheme; import org.apache.hc.client5.http.auth.AuthSchemeProvider; -import org.apache.hc.client5.http.auth.ChallengeType; import org.apache.hc.client5.http.auth.AuthSchemes; +import org.apache.hc.client5.http.auth.ChallengeType; import org.apache.hc.client5.http.config.RequestConfig; import org.apache.hc.client5.http.protocol.HttpClientContext; import org.apache.hc.core5.annotation.Contract; @@ -56,7 +56,7 @@ import org.slf4j.LoggerFactory; * * @since 5.0 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public class DefaultAuthenticationStrategy implements AuthenticationStrategy { private final Logger log = LoggerFactory.getLogger(getClass()); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java index 046cc42bb..3c4c225b0 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultConnectionKeepAliveStrategy.java @@ -42,13 +42,14 @@ import org.apache.hc.core5.util.TimeValue; /** * Default implementation of a strategy deciding duration * that a connection can remain idle. - * + *
* The default implementation looks solely at the 'Keep-Alive' * header's timeout token. + *
* * @since 4.0 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public class DefaultConnectionKeepAliveStrategy implements ConnectionKeepAliveStrategy { public static final DefaultConnectionKeepAliveStrategy INSTANCE = new DefaultConnectionKeepAliveStrategy(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java index 06d522f18..1c8bd5e60 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultHttpRequestRetryHandler.java @@ -54,7 +54,7 @@ import org.apache.hc.core5.util.Args; * * @since 4.0 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public class DefaultHttpRequestRetryHandler implements HttpRequestRetryHandler { public static final DefaultHttpRequestRetryHandler INSTANCE = new DefaultHttpRequestRetryHandler(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultSchemePortResolver.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultSchemePortResolver.java index 9f74e1f47..144ae5f7f 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultSchemePortResolver.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultSchemePortResolver.java @@ -38,7 +38,7 @@ import org.apache.hc.core5.util.Args; * * @since 4.3 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public class DefaultSchemePortResolver implements SchemePortResolver { public static final DefaultSchemePortResolver INSTANCE = new DefaultSchemePortResolver(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultServiceUnavailableRetryStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultServiceUnavailableRetryStrategy.java index b5b0cc238..6c05c6093 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultServiceUnavailableRetryStrategy.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultServiceUnavailableRetryStrategy.java @@ -47,7 +47,7 @@ import org.apache.hc.core5.util.Args; * * @since 4.2 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public class DefaultServiceUnavailableRetryStrategy implements ServiceUnavailableRetryStrategy { /** diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultUserTokenHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultUserTokenHandler.java index 481d91582..87809b81c 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultUserTokenHandler.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/DefaultUserTokenHandler.java @@ -50,10 +50,11 @@ import org.apache.hc.core5.http.protocol.HttpContext; * based authentication schemes such as NTLM or that of the SSL session * with the client authentication turned on. If both are unavailable, * {@code null} token will be returned. + * * * @since 4.0 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public class DefaultUserTokenHandler implements UserTokenHandler { public static final DefaultUserTokenHandler INSTANCE = new DefaultUserTokenHandler(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ExecSupport.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ExecSupport.java index 235d61c8c..c9e42baa4 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ExecSupport.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/ExecSupport.java @@ -28,6 +28,14 @@ package org.apache.hc.client5.http.impl; import java.util.concurrent.atomic.AtomicLong; +import org.apache.hc.core5.annotation.Internal; + +/** + * Request execution support methods. + * + * @since 5.0 + */ +@Internal public final class ExecSupport { private static final AtomicLong COUNT = new AtomicLong(0); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java index d9b5364ae..56da800f7 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/IdleConnectionEvictor.java @@ -30,6 +30,8 @@ package org.apache.hc.client5.http.impl; import java.util.concurrent.ThreadFactory; import java.util.concurrent.TimeUnit; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.concurrent.DefaultThreadFactory; import org.apache.hc.core5.pool.ConnPoolControl; import org.apache.hc.core5.util.Args; @@ -41,6 +43,7 @@ import org.apache.hc.core5.util.TimeValue; * * @since 4.4 */ +@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL) public final class IdleConnectionEvictor { private final ThreadFactory threadFactory; diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/InMemoryDnsResolver.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/InMemoryDnsResolver.java index f915b8c8b..2adf51b01 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/InMemoryDnsResolver.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/InMemoryDnsResolver.java @@ -33,6 +33,8 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import org.apache.hc.client5.http.DnsResolver; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.util.Args; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -42,6 +44,7 @@ import org.slf4j.LoggerFactory; * * @since 4.2 */ +@Contract(threading = ThreadingBehavior.STATELESS) public class InMemoryDnsResolver implements DnsResolver { /** Logger associated to this class. */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/MessageCopier.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/MessageCopier.java index cd152ea40..39220e7db 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/MessageCopier.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/MessageCopier.java @@ -30,7 +30,7 @@ package org.apache.hc.client5.http.impl; import org.apache.hc.core5.http.HttpMessage; /** - * Abstract HTTP message cloner. + * Abstract HTTP message copier. * * @since 5.0 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/NoopUserTokenHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/NoopUserTokenHandler.java index 332796e85..300b20f41 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/NoopUserTokenHandler.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/NoopUserTokenHandler.java @@ -37,7 +37,7 @@ import org.apache.hc.core5.http.protocol.HttpContext; * * @since 4.3 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public class NoopUserTokenHandler implements UserTokenHandler { public static final NoopUserTokenHandler INSTANCE = new NoopUserTokenHandler(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Operations.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Operations.java index 94e5df96c..da15e56e5 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Operations.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/Operations.java @@ -34,6 +34,11 @@ import java.util.concurrent.TimeoutException; import org.apache.hc.core5.concurrent.Cancellable; +/** + * Common cancellable operations. + * + * @since 5.0 + */ public final class Operations { private final static Cancellable NOOP_CANCELLABLE = new Cancellable() { @@ -45,6 +50,12 @@ public final class Operations { }; + /** + * This class represents a {@link Future} in the completed state with a fixed result. + * The outcome of the future cannot be altered and it cannot be cancelled. + * + * @param* Further responsibilities such as communication with the opposite * endpoint is delegated to the next executor in the request execution * chain. + *
* * @since 5.0 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) -class AsyncProtocolExec implements AsyncExecChainHandler { +@Contract(threading = ThreadingBehavior.STATELESS) +@Internal +public final class AsyncProtocolExec implements AsyncExecChainHandler { private final Logger log = LoggerFactory.getLogger(getClass()); @@ -191,7 +194,7 @@ class AsyncProtocolExec implements AsyncExecChainHandler { @Override public void completed() { - if (!execRuntime.isConnected()) { + if (!execRuntime.isEndpointConnected()) { if (proxyAuthExchange.getState() == AuthExchange.State.SUCCESS && proxyAuthExchange.isConnectionBased()) { log.debug("Resetting proxy auth state"); @@ -267,11 +270,11 @@ class AsyncProtocolExec implements AsyncExecChainHandler { proxy, ChallengeType.PROXY, response, proxyAuthExchange, context); if (targetAuthRequested) { - return authenticator.prepareAuthResponse(target, ChallengeType.TARGET, response, + return authenticator.updateAuthState(target, ChallengeType.TARGET, response, targetAuthStrategy, targetAuthExchange, context); } if (proxyAuthRequested) { - return authenticator.prepareAuthResponse(proxy, ChallengeType.PROXY, response, + return authenticator.updateAuthState(proxy, ChallengeType.PROXY, response, proxyAuthStrategy, proxyAuthExchange, context); } } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java index 1904efca0..540c03f26 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRedirectExec.java @@ -43,6 +43,9 @@ import org.apache.hc.client5.http.protocol.RedirectLocations; import org.apache.hc.client5.http.protocol.RedirectStrategy; import org.apache.hc.client5.http.routing.HttpRoutePlanner; import org.apache.hc.client5.http.utils.URIUtils; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.Internal; +import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.http.EntityDetails; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpHost; @@ -57,7 +60,20 @@ import org.apache.hc.core5.util.LangUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -class AsyncRedirectExec implements AsyncExecChainHandler { +/** + * Request execution handler in the asynchronous request execution chain + * responsbile for handling of request redirects. + *+ * Further responsibilities such as communication with the opposite + * endpoint is delegated to the next executor in the request execution + * chain. + *
+ * + * @since 5.0 + */ +@Contract(threading = ThreadingBehavior.STATELESS) +@Internal +public final class AsyncRedirectExec implements AsyncExecChainHandler { private final Logger log = LoggerFactory.getLogger(getClass()); @@ -183,7 +199,7 @@ class AsyncRedirectExec implements AsyncExecChainHandler { } else { try { if (state.reroute) { - scope.execRuntime.releaseConnection(); + scope.execRuntime.releaseEndpoint(); } internalExecute(state, chain, asyncExecCallback); } catch (final IOException | HttpException ex) { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRetryExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRetryExec.java index 1118ed3ab..a484b110c 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRetryExec.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/AsyncRetryExec.java @@ -35,6 +35,9 @@ import org.apache.hc.client5.http.async.AsyncExecChain; import org.apache.hc.client5.http.async.AsyncExecChainHandler; import org.apache.hc.client5.http.impl.RequestCopier; import org.apache.hc.client5.http.protocol.HttpClientContext; +import org.apache.hc.core5.annotation.Contract; +import org.apache.hc.core5.annotation.Internal; +import org.apache.hc.core5.annotation.ThreadingBehavior; import org.apache.hc.core5.http.EntityDetails; import org.apache.hc.core5.http.HttpException; import org.apache.hc.core5.http.HttpRequest; @@ -45,7 +48,21 @@ import org.apache.hc.core5.util.Args; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -class AsyncRetryExec implements AsyncExecChainHandler { +/** + * Request execution handler in the asynchronous request execution chain + * responsbile for making a decision whether a request failed due to + * an I/O error should be re-executed. + *+ * Further responsibilities such as communication with the opposite + * endpoint is delegated to the next executor in the request execution + * chain. + *
+ * + * @since 5.0 + */ +@Contract(threading = ThreadingBehavior.STATELESS) +@Internal +public final class AsyncRetryExec implements AsyncExecChainHandler { private final Logger log = LoggerFactory.getLogger(getClass()); @@ -100,7 +117,7 @@ class AsyncRetryExec implements AsyncExecChainHandler { log.info("Retrying request to " + route); } try { - scope.execRuntime.discardConnection(); + scope.execRuntime.discardEndpoint(); if (entityProducer != null) { entityProducer.releaseResources(); } diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java index 65dbe51b0..46bbbb83b 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/CloseableHttpAsyncClient.java @@ -54,9 +54,9 @@ import org.apache.hc.core5.util.TimeValue; /** * Base implementation of {@link HttpAsyncClient} that also implements {@link Closeable}. * - * @since 4.0 + * @since 5.0 */ -@Contract(threading = ThreadingBehavior.SAFE) +@Contract(threading = ThreadingBehavior.STATELESS) public abstract class CloseableHttpAsyncClient implements HttpAsyncClient, Closeable { public abstract void start(); diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientBuilder.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientBuilder.java index e1f1cbe34..6e9e17b9a 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientBuilder.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/async/Http2AsyncClientBuilder.java @@ -53,7 +53,7 @@ import org.apache.hc.client5.http.cookie.BasicCookieStore; import org.apache.hc.client5.http.cookie.CookieSpecProvider; import org.apache.hc.client5.http.cookie.CookieStore; import org.apache.hc.client5.http.impl.ChainElements; -import org.apache.hc.client5.http.impl.CookieSpecRegistries; +import org.apache.hc.client5.http.impl.CookieSpecSupport; import org.apache.hc.client5.http.impl.DefaultAuthenticationStrategy; import org.apache.hc.client5.http.impl.DefaultHttpRequestRetryHandler; import org.apache.hc.client5.http.impl.DefaultRedirectStrategy; @@ -116,10 +116,16 @@ import org.apache.hc.core5.util.TimeValue; import org.apache.hc.core5.util.VersionInfo; /** - * Builder for HTTP/2 {@link CloseableHttpAsyncClient} instances. + * Builder for HTTP/2 only {@link CloseableHttpAsyncClient} instances. + *+ * Concurrent message exchanges with the same connection route executed + * with these {@link CloseableHttpAsyncClient} instances will get + * automatically multiplexed over a single physical HTTP/2 connection. + *
** When a particular component is not explicitly set this class will * use its default implementation. + *
*
* @since 5.0
*/
@@ -769,7 +775,7 @@ public class Http2AsyncClientBuilder {
}
Lookup
+ * Concurrent message exchanges executed by {@link CloseableHttpAsyncClient}
+ * instances created with this builder will get automatically assigned to
+ * separate connections leased from the connection pool.
+ *
* When a particular component is not explicitly set this class will
* use its default implementation. System properties will be taken
@@ -975,7 +982,7 @@ public class HttpAsyncClientBuilder {
}
Lookup
+ * Concurrent message exchanges with the same connection route executed by
+ * this client will get automatically multiplexed over a single physical HTTP/2
+ * connection.
+ *
+ * Concurrent message exchanges executed by this client will get assigned to
+ * separate connections leased from the connection pool.
+ *
+ * Concurrent message exchanges with the same connection route executed by
+ * this client will get automatically multiplexed over a single physical HTTP/2
+ * connection.
+ *
+ * Concurrent message exchanges executed by this client will get assigned to
+ * separate connections leased from the connection pool.
+ *
* Client implementation of the CredSSP protocol specified in [MS-CSSP].
- *
* Note: This is implementation is NOT GSS based. It should be. But there is no Java NTLM
* implementation as GSS module. Maybe the NTLMEngine can be converted to GSS and then this
@@ -76,6 +74,8 @@ import org.slf4j.LoggerFactory;
* Based on [MS-CSSP]: Credential Security Support Provider (CredSSP) Protocol (Revision 13.0, 7/14/2016).
* The implementation was inspired by Python CredSSP and NTLM implementation by Jordan Borean.
*
+ * Please note this class is considered experimental and may be discontinued or removed
+ * in the future.
+ *
+ * Please note this class is considered experimental and may be discontinued or removed
+ * in the future.
+ *
+ * Please note this class is considered experimental and may be discontinued or removed
+ * in the future.
+ *
+ * Please note this class is considered experimental and may be discontinued or removed
+ * in the future.
+ *
+ * Further responsibilities such as communication with the opposite
+ * endpoint is delegated to the next executor in the request execution
+ * chain.
+ *
* Further responsibilities such as communication with the opposite
* endpoint is delegated to the next executor in the request execution
@@ -65,7 +66,8 @@ import org.apache.hc.core5.util.Args;
*
* @since 5.0
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
+@Contract(threading = ThreadingBehavior.STATELESS)
+@Internal
public final class ContentCompressionExec implements ExecChainHandler {
private final String[] acceptEncoding;
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/DefaultBackoffStrategy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/DefaultBackoffStrategy.java
index 7f2ab149e..c78108a78 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/DefaultBackoffStrategy.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/DefaultBackoffStrategy.java
@@ -30,6 +30,7 @@ import java.net.ConnectException;
import java.net.SocketTimeoutException;
import org.apache.hc.client5.http.classic.ConnectionBackoffStrategy;
+import org.apache.hc.core5.annotation.Experimental;
import org.apache.hc.core5.http.HttpResponse;
import org.apache.hc.core5.http.HttpStatus;
@@ -40,6 +41,7 @@ import org.apache.hc.core5.http.HttpStatus;
*
* @since 4.2
*/
+@Experimental
public class DefaultBackoffStrategy implements ConnectionBackoffStrategy {
@Override
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/FutureRequestExecutionService.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/FutureRequestExecutionService.java
index 82b5f7b30..464b5f598 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/FutureRequestExecutionService.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/FutureRequestExecutionService.java
@@ -29,6 +29,7 @@ package org.apache.hc.client5.http.impl.classic;
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.ExecutorService;
+import java.util.concurrent.FutureTask;
import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.hc.client5.http.classic.HttpClient;
@@ -40,8 +41,8 @@ import org.apache.hc.core5.http.io.HttpClientResponseHandler;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
- * HttpAsyncClientWithFuture wraps calls to execute with a {@link HttpRequestFutureTask}
- * and schedules them using the provided executor service. Scheduled calls may be cancelled.
+ * This class schedules message execution execution and processing
+ * as {@link FutureTask}s with the provided {@link ExecutorService}.
*/
@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
public class FutureRequestExecutionService implements Closeable {
@@ -82,7 +83,7 @@ public class FutureRequestExecutionService implements Closeable {
* handler that will process the response.
* @return HttpAsyncClientFutureTask for the scheduled request.
*/
- public
+ * Concurrent message exchanges executed by this client will get assigned to
+ * separate connections leased from the connection pool.
+ *
+ * Concurrent message exchanges executed by this client will get assigned to
+ * separate connections leased from the connection pool.
+ *
* Further responsibilities such as communication with the opposite
* endpoint is delegated to the next executor in the request execution
@@ -77,8 +78,9 @@ import org.slf4j.LoggerFactory;
*
* @since 4.3
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
-final class ProtocolExec implements ExecChainHandler {
+@Contract(threading = ThreadingBehavior.STATELESS)
+@Internal
+public final class ProtocolExec implements ExecChainHandler {
private final Logger log = LoggerFactory.getLogger(getClass());
@@ -179,7 +181,7 @@ final class ProtocolExec implements ExecChainHandler {
if (execRuntime.isConnectionReusable()) {
EntityUtils.consume(responseEntity);
} else {
- execRuntime.disconnect();
+ execRuntime.disconnectEndpoint();
if (proxyAuthExchange.getState() == AuthExchange.State.SUCCESS
&& proxyAuthExchange.isConnectionBased()) {
log.debug("Resetting proxy auth state");
@@ -202,10 +204,10 @@ final class ProtocolExec implements ExecChainHandler {
}
}
} catch (final HttpException ex) {
- execRuntime.discardConnection();
+ execRuntime.discardEndpoint();
throw ex;
} catch (final RuntimeException | IOException ex) {
- execRuntime.discardConnection();
+ execRuntime.discardEndpoint();
if (proxyAuthExchange.isConnectionBased()) {
proxyAuthExchange.reset();
}
@@ -238,11 +240,11 @@ final class ProtocolExec implements ExecChainHandler {
proxy, ChallengeType.PROXY, response, proxyAuthExchange, context);
if (targetAuthRequested) {
- return authenticator.prepareAuthResponse(target, ChallengeType.TARGET, response,
+ return authenticator.updateAuthState(target, ChallengeType.TARGET, response,
targetAuthStrategy, targetAuthExchange, context);
}
if (proxyAuthRequested) {
- return authenticator.prepareAuthResponse(proxy, ChallengeType.PROXY, response,
+ return authenticator.updateAuthState(proxy, ChallengeType.PROXY, response,
proxyAuthStrategy, proxyAuthExchange, context);
}
}
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java
index 7be98fb46..f47c2dfd0 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ProxyClient.java
@@ -83,7 +83,7 @@ import org.apache.hc.core5.http.protocol.RequestUserAgent;
import org.apache.hc.core5.util.Args;
/**
- * ProxyClient can be used to establish a tunnel via an HTTP proxy.
+ * ProxyClient can be used to establish a tunnel via an HTTP/1.1 proxy.
*/
public class ProxyClient {
@@ -186,7 +186,7 @@ public class ProxyClient {
throw new HttpException("Unexpected response to CONNECT request: " + response);
}
if (this.authenticator.isChallenged(proxy, ChallengeType.PROXY, response, this.proxyAuthExchange, context)) {
- if (this.authenticator.prepareAuthResponse(proxy, ChallengeType.PROXY, response,
+ if (this.authenticator.updateAuthState(proxy, ChallengeType.PROXY, response,
this.proxyAuthStrategy, this.proxyAuthExchange, context)) {
// Retry request
if (this.reuseStrategy.keepAlive(connect, response, context)) {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java
index 848d2eb8a..7ada6b3c1 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RedirectExec.java
@@ -46,6 +46,7 @@ import org.apache.hc.client5.http.protocol.RedirectStrategy;
import org.apache.hc.client5.http.routing.HttpRoutePlanner;
import org.apache.hc.client5.http.utils.URIUtils;
import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.Internal;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
@@ -61,8 +62,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Request executor in the request execution chain that is responsible
- * for handling of request redirects.
+ * Request execution handler in the classic request execution chain
+ * responsible for handling of request redirects.
*
* Further responsibilities such as communication with the opposite
* endpoint is delegated to the next executor in the request execution
@@ -71,8 +72,9 @@ import org.slf4j.LoggerFactory;
*
* @since 4.3
*/
-@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
-final class RedirectExec implements ExecChainHandler {
+@Contract(threading = ThreadingBehavior.STATELESS)
+@Internal
+public final class RedirectExec implements ExecChainHandler {
private final Logger log = LoggerFactory.getLogger(getClass());
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RequestEntityProxy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RequestEntityProxy.java
index 4a9b81a82..e7e4835ed 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RequestEntityProxy.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RequestEntityProxy.java
@@ -37,11 +37,6 @@ import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.Header;
import org.apache.hc.core5.http.HttpEntity;
-/**
- * A Proxy class for {@link org.apache.hc.core5.http.HttpEntity} enclosed in a request message.
- *
- * @since 4.3
- */
class RequestEntityProxy implements HttpEntity {
static void enhance(final ClassicHttpRequest request) {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ResponseEntityProxy.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ResponseEntityProxy.java
index 9dc55046b..fb6182b59 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ResponseEntityProxy.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ResponseEntityProxy.java
@@ -39,11 +39,6 @@ import org.apache.hc.core5.http.io.EofSensorInputStream;
import org.apache.hc.core5.http.io.EofSensorWatcher;
import org.apache.hc.core5.http.io.entity.HttpEntityWrapper;
-/**
- * A wrapper class for {@link HttpEntity} enclosed in a response message.
- *
- * @since 4.3
- */
class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher {
private final ExecRuntime execRuntime;
@@ -62,22 +57,22 @@ class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher
private void cleanup() throws IOException {
if (this.execRuntime != null) {
- if (this.execRuntime.isConnected()) {
- this.execRuntime.disconnect();
+ if (this.execRuntime.isEndpointConnected()) {
+ this.execRuntime.disconnectEndpoint();
}
- this.execRuntime.discardConnection();
+ this.execRuntime.discardEndpoint();
}
}
private void discardConnection() {
if (this.execRuntime != null) {
- this.execRuntime.discardConnection();
+ this.execRuntime.discardEndpoint();
}
}
public void releaseConnection() {
if (this.execRuntime != null) {
- this.execRuntime.releaseConnection();
+ this.execRuntime.releaseEndpoint();
}
}
@@ -127,7 +122,7 @@ class ResponseEntityProxy extends HttpEntityWrapper implements EofSensorWatcher
@Override
public boolean streamClosed(final InputStream wrapped) throws IOException {
try {
- final boolean open = execRuntime != null && execRuntime.isConnectionAcquired();
+ final boolean open = execRuntime != null && execRuntime.isEndpointAcquired();
// this assumes that closing the stream will
// consume the remainder of the response body:
try {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java
index 7fa9343c2..1c98ec3d1 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/RetryExec.java
@@ -35,6 +35,7 @@ import org.apache.hc.client5.http.classic.ExecChain;
import org.apache.hc.client5.http.classic.ExecChainHandler;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.Internal;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
@@ -46,9 +47,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Request executor in the request execution chain that is responsible
- * for making a decision whether a request failed due to an I/O error
- * should be re-executed.
+ * Request execution handler in the classic request execution chain
+ * responsible for making a decision whether a request failed due to
+ * an I/O error should be re-executed.
*
* Further responsibilities such as communication with the opposite
* endpoint is delegated to the next executor in the request execution
@@ -57,8 +58,9 @@ import org.slf4j.LoggerFactory;
*
* @since 4.3
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
-final class RetryExec implements ExecChainHandler {
+@Contract(threading = ThreadingBehavior.STATELESS)
+@Internal
+public final class RetryExec implements ExecChainHandler {
private final Logger log = LoggerFactory.getLogger(getClass());
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ServiceUnavailableRetryExec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ServiceUnavailableRetryExec.java
index 285d4d872..28d4a6ceb 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ServiceUnavailableRetryExec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/ServiceUnavailableRetryExec.java
@@ -35,6 +35,7 @@ import org.apache.hc.client5.http.classic.ExecChain;
import org.apache.hc.client5.http.classic.ExecChainHandler;
import org.apache.hc.client5.http.protocol.HttpClientContext;
import org.apache.hc.core5.annotation.Contract;
+import org.apache.hc.core5.annotation.Internal;
import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.ClassicHttpRequest;
import org.apache.hc.core5.http.ClassicHttpResponse;
@@ -56,8 +57,9 @@ import org.slf4j.LoggerFactory;
*
* @since 4.3
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
-final class ServiceUnavailableRetryExec implements ExecChainHandler {
+@Contract(threading = ThreadingBehavior.STATELESS)
+@Internal
+public final class ServiceUnavailableRetryExec implements ExecChainHandler {
private final Logger log = LoggerFactory.getLogger(getClass());
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/SystemClock.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/SystemClock.java
index 0ec51d776..fffca7ef4 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/SystemClock.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/SystemClock.java
@@ -26,11 +26,6 @@
*/
package org.apache.hc.client5.http.impl.classic;
-/**
- * The actual system clock.
- *
- * @since 4.2
- */
class SystemClock implements Clock {
@Override
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/package-info.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/package-info.java
index 20c017ddc..2447808d3 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/package-info.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/classic/package-info.java
@@ -26,27 +26,8 @@
*/
/**
- * Default HTTP client implementation.
- *
- * The usual execution flow can be demonstrated by the code snippet below:
- *
+ * Once the endpoint is no longer needed it MUST be released with {@link #close(org.apache.hc.core5.io.CloseMode)} )}.
+ *
+ * Once the endpoint is no longer needed it MUST be released with {@link #close(org.apache.hc.core5.io.CloseMode)}.
+ *
* Implementations of this interface must be thread-safe. Access to shared
* data must be synchronized as methods of this interface may be executed
* from multiple threads.
+ *
* Implementations of this interface must be thread-safe. Access to shared
* data must be synchronized as methods of this interface may be executed
* from multiple threads.
+ *
- * CloseableHttpClient httpclient = HttpClients.createDefault();
- * try {
- * HttpGet httpGet = new HttpGet("http://targethost/homepage");
- * CloseableHttpResponse response = httpclient.execute(httpGet);
- * try {
- * System.out.println(response.getStatusLine());
- * HttpEntity entity = response.getEntity();
- * // do something useful with the response body
- * // and ensure it is fully consumed
- * EntityUtils.consume(entity);
- * } finally {
- * response.close();
- * }
- * } finally {
- * httpclient.close();
- * }
- *
+ * Classic HTTP client API implementation that supports HTTP/1.1 transport
+ * only. This implementation is mostly API compatible with HttpClient 4.5.
+ * Please use the asynchronous client API implementation for HTTP/2 transport.
*/
package org.apache.hc.client5.http.impl.classic;
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieAttributeHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieAttributeHandler.java
index 242392327..fe72c0913 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieAttributeHandler.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieAttributeHandler.java
@@ -37,7 +37,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
*
* @since 4.0
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
+@Contract(threading = ThreadingBehavior.STATELESS)
public abstract class AbstractCookieAttributeHandler implements CookieAttributeHandler {
@Override
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieSpec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieSpec.java
index d6f8707c4..6a92c4e15 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieSpec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/AbstractCookieSpec.java
@@ -44,7 +44,6 @@ import org.apache.hc.core5.util.Asserts;
* validation or matching cookie attributes to a number of arbitrary
* {@link CookieAttributeHandler}s.
*
- *
* @since 4.0
*/
@Contract(threading = ThreadingBehavior.SAFE)
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java
index 4ded0355f..62fb23348 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicClientCookie.java
@@ -41,7 +41,7 @@ import org.apache.hc.core5.util.Args;
*
* @since 4.0
*/
-public class BasicClientCookie implements SetCookie, Cloneable, Serializable {
+public final class BasicClientCookie implements SetCookie, Cloneable, Serializable {
private static final long serialVersionUID = -3869795591041535538L;
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java
index bfed82a00..edbf78e3f 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicDomainHandler.java
@@ -41,10 +41,11 @@ import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.TextUtils;
/**
+ * Cookie {@code domain} attribute handler.
*
* @since 4.0
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
+@Contract(threading = ThreadingBehavior.STATELESS)
public class BasicDomainHandler implements CommonCookieAttributeHandler {
public BasicDomainHandler() {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicExpiresHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicExpiresHandler.java
index d90dfafcf..1c01784e0 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicExpiresHandler.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicExpiresHandler.java
@@ -38,10 +38,11 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
/**
+ * Cookie {@code expires} attribute handler.
*
* @since 4.0
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
+@Contract(threading = ThreadingBehavior.STATELESS)
public class BasicExpiresHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
/** Valid date patterns */
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicMaxAgeHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicMaxAgeHandler.java
index 74cba3375..599ad2c40 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicMaxAgeHandler.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicMaxAgeHandler.java
@@ -37,10 +37,11 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
/**
+ * Cookie {@code max-age} attribute handler.
*
* @since 4.0
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
+@Contract(threading = ThreadingBehavior.STATELESS)
public class BasicMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
public BasicMaxAgeHandler() {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java
index 43752d77b..9de0403f9 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicPathHandler.java
@@ -37,10 +37,11 @@ import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.TextUtils;
/**
+ * Cookie {@code path} attribute handler.
*
* @since 4.0
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
+@Contract(threading = ThreadingBehavior.STATELESS)
public class BasicPathHandler implements CommonCookieAttributeHandler {
public BasicPathHandler() {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicSecureHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicSecureHandler.java
index 99406a7d6..e8a3060b4 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicSecureHandler.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/BasicSecureHandler.java
@@ -36,10 +36,11 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
/**
+ * Cookie {@code secure} attribute handler.
*
* @since 4.0
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
+@Contract(threading = ThreadingBehavior.STATELESS)
public class BasicSecureHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
public BasicSecureHandler() {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/CookieSpecBase.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/CookieSpecBase.java
index dd10e2f42..af9782214 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/CookieSpecBase.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/CookieSpecBase.java
@@ -48,7 +48,7 @@ import org.apache.hc.core5.util.Args;
*
* @since 4.0
*/
-@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
+@Contract(threading = ThreadingBehavior.SAFE)
public abstract class CookieSpecBase extends AbstractCookieSpec {
public CookieSpecBase() {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpec.java
index fee891103..018641c1f 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpec.java
@@ -42,7 +42,7 @@ import org.apache.hc.core5.http.Header;
*
* @since 4.1
*/
-@Contract(threading = ThreadingBehavior.SAFE)
+@Contract(threading = ThreadingBehavior.STATELESS)
public class IgnoreSpec extends CookieSpecBase {
@Override
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpecProvider.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpecProvider.java
index e7bf1fcad..38b0879c7 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpecProvider.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/IgnoreSpecProvider.java
@@ -34,11 +34,11 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
- * {@link org.apache.hc.client5.http.cookie.CookieSpecProvider} implementation that ignores all cookies.
+ * {@link CookieSpecProvider} implementation that ignores all cookies.
*
* @since 4.4
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
+@Contract(threading = ThreadingBehavior.SAFE)
public class IgnoreSpecProvider implements CookieSpecProvider {
private volatile CookieSpec cookieSpec;
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java
index c75435d0b..ea4ae56ed 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxExpiresHandler.java
@@ -45,10 +45,12 @@ import org.apache.hc.core5.http.message.ParserCursor;
import org.apache.hc.core5.util.Args;
/**
+ * Cookie {@code expires} attribute handler conformant to the more relaxed interpretation
+ * of HTTP state management.
*
* @since 4.4
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
+@Contract(threading = ThreadingBehavior.STATELESS)
public class LaxExpiresHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
static final TimeZone UTC = TimeZone.getTimeZone("UTC");
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxMaxAgeHandler.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxMaxAgeHandler.java
index cf3639cfa..a1d2f7fe3 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxMaxAgeHandler.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/LaxMaxAgeHandler.java
@@ -40,10 +40,12 @@ import org.apache.hc.core5.util.Args;
import org.apache.hc.core5.util.TextUtils;
/**
+ * Cookie {@code max-age} attribute handler conformant to the more relaxed interpretation
+ * of HTTP state management.
*
* @since 4.4
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
+@Contract(threading = ThreadingBehavior.STATELESS)
public class LaxMaxAgeHandler extends AbstractCookieAttributeHandler implements CommonCookieAttributeHandler {
private final static Pattern MAX_AGE_PATTERN = Pattern.compile("^\\-?[0-9]+$");
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/PublicSuffixDomainFilter.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/PublicSuffixDomainFilter.java
index 3022f8e05..1ae0c25b0 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/PublicSuffixDomainFilter.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/PublicSuffixDomainFilter.java
@@ -41,17 +41,17 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.util.Args;
/**
- * Wraps a {@link org.apache.hc.client5.http.cookie.CookieAttributeHandler} and leverages its match method
- * to never match a suffix from a black list. May be used to provide additional security for
- * cross-site attack types by preventing cookies from apparent domains that are not publicly
- * available.
+ * Wraps a {@link org.apache.hc.client5.http.cookie.CookieAttributeHandler} and leverages
+ * its match method to never match a suffix from a black list. May be used to provide
+ * additional security for cross-site attack types by preventing cookies from apparent
+ * domains that are not publicly available.
*
* @see PublicSuffixList
* @see PublicSuffixMatcher
*
* @since 4.4
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
+@Contract(threading = ThreadingBehavior.STATELESS)
public class PublicSuffixDomainFilter implements CommonCookieAttributeHandler {
private final CommonCookieAttributeHandler handler;
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java
index 3af14c34c..9ec499edb 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpec.java
@@ -60,7 +60,7 @@ import org.apache.hc.core5.util.CharArrayBuffer;
*
* @since 4.5
*/
-@Contract(threading = ThreadingBehavior.SAFE_CONDITIONAL)
+@Contract(threading = ThreadingBehavior.SAFE)
public class RFC6265CookieSpec implements CookieSpec {
private final static char PARAM_DELIMITER = ';';
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpecProvider.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpecProvider.java
index adaa7ef3d..77339432b 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpecProvider.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265CookieSpecProvider.java
@@ -38,13 +38,13 @@ import org.apache.hc.core5.annotation.ThreadingBehavior;
import org.apache.hc.core5.http.protocol.HttpContext;
/**
- * {@link org.apache.hc.client5.http.cookie.CookieSpecProvider} implementation that provides an instance of
- * RFC 6265 conformant cookie policy. The instance returned by this factory can be shared by
- * multiple threads.
+ * {@link CookieSpecProvider} implementation that provides an instance of
+ * RFC 6265 conformant cookie policy. The instance returned by this factory
+ * can be shared by multiple threads.
*
* @since 4.4
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
+@Contract(threading = ThreadingBehavior.SAFE)
public class RFC6265CookieSpecProvider implements CookieSpecProvider {
public enum CompatibilityLevel {
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265LaxSpec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265LaxSpec.java
index 0514df39c..56fed126f 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265LaxSpec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265LaxSpec.java
@@ -32,8 +32,8 @@ import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
/**
- * Standard {@link org.apache.hc.client5.http.cookie.CookieSpec} implementation that enforces a more relaxed
- * interpretation of the HTTP state management specification (RFC 6265, section 5)
+ * Standard {@link org.apache.hc.client5.http.cookie.CookieSpec} implementation that enforces
+ * a more relaxed interpretation of the HTTP state management specification (RFC 6265, section 5)
* for interoperability with existing servers that do not conform to the well behaved profile
* (RFC 6265, section 4).
*
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265StrictSpec.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265StrictSpec.java
index 774753c8b..22ec3e02a 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265StrictSpec.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/RFC6265StrictSpec.java
@@ -33,9 +33,9 @@ import org.apache.hc.core5.annotation.Contract;
import org.apache.hc.core5.annotation.ThreadingBehavior;
/**
- * Standard {@link org.apache.hc.client5.http.cookie.CookieSpec} implementation that enforces syntax
- * and semantics of the well-behaved profile of the HTTP state management specification
- * (RFC 6265, section 4).
+ * Standard {@link org.apache.hc.client5.http.cookie.CookieSpec} implementation
+ * that enforces syntax and semantics of the well-behaved profile of the HTTP
+ * state management specification (RFC 6265, section 4).
*
* @since 4.4
*/
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/package-info.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/package-info.java
index adc45f1e4..d76c2ebcb 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/package-info.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/cookie/package-info.java
@@ -26,7 +26,6 @@
*/
/**
- * Default implementations of standard and common HTTP state
- * management policies.
+ * Standard and common HTTP cookie management policies.
*/
package org.apache.hc.client5.http.impl.cookie;
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java
index bf915fded..785aa5c2a 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpClientConnectionOperator.java
@@ -67,7 +67,7 @@ import org.slf4j.LoggerFactory;
* @since 4.4
*/
@Internal
-@Contract(threading = ThreadingBehavior.IMMUTABLE_CONDITIONAL)
+@Contract(threading = ThreadingBehavior.STATELESS)
public class DefaultHttpClientConnectionOperator implements HttpClientConnectionOperator {
static final String SOCKET_FACTORY_REGISTRY = "http.socket-factory-registry";
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java
index 6859d28e3..f61eeb721 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/io/DefaultHttpResponseParserFactory.java
@@ -43,7 +43,7 @@ import org.apache.hc.core5.http.message.LineParser;
*
* @since 4.3
*/
-@Contract(threading = ThreadingBehavior.IMMUTABLE)
+@Contract(threading = ThreadingBehavior.STATELESS)
public class DefaultHttpResponseParserFactory implements HttpMessageParserFactory
* An up-to-date list of suffixes can be obtained from * publicsuffix.org + *
* * @since 4.4 */ diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixListParser.java b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixListParser.java index 730791a3d..9619d5db2 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixListParser.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixListParser.java @@ -41,7 +41,7 @@ import org.apache.hc.core5.annotation.ThreadingBehavior; * * @since 4.4 */ -@Contract(threading = ThreadingBehavior.IMMUTABLE) +@Contract(threading = ThreadingBehavior.STATELESS) public final class PublicSuffixListParser { public PublicSuffixListParser() { diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java index 5c4c6a1d1..9b7dd5704 100644 --- a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/PublicSuffixMatcher.java @@ -42,6 +42,7 @@ import org.apache.hc.core5.util.Args; ** An up-to-date list of suffixes can be obtained from * publicsuffix.org + *
* * @see PublicSuffixList * diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/psl/package-info.java b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/package-info.java new file mode 100644 index 000000000..dc16f42fe --- /dev/null +++ b/httpclient5/src/main/java/org/apache/hc/client5/http/psl/package-info.java @@ -0,0 +1,31 @@ +/* + * ==================================================================== + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + *