You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2019/04/02 13:32:46 UTC

[httpcomponents-client] branch release-preparation updated (1b90df5 -> 9710652)

This is an automated email from the ASF dual-hosted git repository.

olegk pushed a change to branch release-preparation
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git.


 discard 1b90df5  [HTTPCORE-572] Move examples to the src/test folders for each module
     add adf8691  HTTPCLIENT-1976: Unsafe deserialization in DefaultHttpCacheEntrySerializer
     add e684490  Merge branch 'HTTPCLIENT-1976'
     new c44a10d  [HTTPCORE-572] Move examples to the src/test folders for each module
     new 9710652  Updated release notes for HttpClient 5.0-beta4 release

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (1b90df5)
            \
             N -- N -- N   refs/heads/release-preparation (9710652)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 RELEASE_NOTES.txt                                  | 91 ++++++++++++++++++----
 .../impl/cache/ByteArrayCacheEntrySerializer.java  | 55 ++++++++++++-
 .../cache/TestByteArrayCacheEntrySerializer.java   | 40 ++++++++++
 3 files changed, 168 insertions(+), 18 deletions(-)


[httpcomponents-client] 01/02: [HTTPCORE-572] Move examples to the src/test folders for each module

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch release-preparation
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git

commit c44a10df752dfce7071fa912a183e2454076a1ed
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Tue Apr 2 11:21:37 2019 +0200

    [HTTPCORE-572] Move examples to the src/test folders for each module
---
 .../hc/client5/http/examples/fluent/FluentAsync.java   | 16 ++++++++--------
 .../client5/http/examples/fluent/FluentExecutor.java   |  4 ++--
 .../client5/http/examples/fluent/FluentQuickStart.java |  2 +-
 .../client5/http/examples/fluent/FluentRequests.java   |  2 +-
 .../http/examples/fluent/FluentResponseHandling.java   | 18 +++++++++---------
 .../http/examples/AsyncClientAuthentication.java       |  8 ++++----
 .../http/examples/AsyncClientConnectionEviction.java   |  0
 .../hc/client5/http/examples/AsyncClientCustomSSL.java |  4 ++--
 .../http/examples/AsyncClientFullDuplexExchange.java   |  0
 .../http/examples/AsyncClientHttp1Pipelining.java      |  0
 .../examples/AsyncClientHttp2FullDuplexExchange.java   |  0
 .../http/examples/AsyncClientHttp2Multiplexing.java    |  0
 .../http/examples/AsyncClientHttp2ServerPush.java      |  0
 .../client5/http/examples/AsyncClientHttpExchange.java |  0
 .../examples/AsyncClientHttpExchangeStreaming.java     |  0
 .../client5/http/examples/AsyncClientInterceptors.java | 10 +++++-----
 .../http/examples/AsyncClientMessageTrailers.java      |  0
 .../hc/client5/http/examples/AsyncClientTlsAlpn.java   |  2 +-
 .../hc/client5/http/examples/AsyncQuickStart.java      | 10 +++++-----
 .../hc/client5/http/examples/ClientAbortMethod.java    |  6 +++---
 .../hc/client5/http/examples/ClientAuthentication.java |  4 ++--
 .../client5/http/examples/ClientChunkEncodedPost.java  |  4 ++--
 .../hc/client5/http/examples/ClientConfiguration.java  |  4 ++--
 .../client5/http/examples/ClientConnectionRelease.java |  6 +++---
 .../hc/client5/http/examples/ClientCustomContext.java  |  6 +++---
 .../http/examples/ClientCustomPublicSuffixList.java    |  6 +++---
 .../hc/client5/http/examples/ClientCustomSSL.java      |  0
 .../http/examples/ClientEvictExpiredConnections.java   |  7 +++----
 .../hc/client5/http/examples/ClientExecuteProxy.java   |  4 ++--
 .../hc/client5/http/examples/ClientExecuteSOCKS.java   |  6 +++---
 .../hc/client5/http/examples/ClientFormLogin.java      |  6 +++---
 .../hc/client5/http/examples/ClientInterceptors.java   | 10 +++++-----
 .../http/examples/ClientMultiThreadedExecution.java    | 10 +++++-----
 .../client5/http/examples/ClientMultipartFormPost.java |  4 ++--
 .../examples/ClientPreemptiveBasicAuthentication.java  |  4 ++--
 .../examples/ClientPreemptiveDigestAuthentication.java |  6 +++---
 .../http/examples/ClientProxyAuthentication.java       |  4 ++--
 .../client5/http/examples/ClientWithRequestFuture.java |  2 +-
 .../http/examples/ClientWithResponseHandler.java       |  4 ++--
 .../hc/client5/http/examples/ProxyTunnelDemo.java      |  2 +-
 .../apache/hc/client5/http/examples/QuickStart.java    |  6 +++---
 .../examples/ReactiveClientFullDuplexExchange.java     |  4 ++--
 42 files changed, 95 insertions(+), 96 deletions(-)

diff --git a/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentAsync.java b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentAsync.java
similarity index 84%
rename from httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentAsync.java
rename to httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentAsync.java
index 476709e..29d87d1 100644
--- a/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentAsync.java
+++ b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentAsync.java
@@ -44,12 +44,12 @@ import org.apache.hc.core5.concurrent.FutureCallback;
  */
 public class FluentAsync {
 
-    public static void main(String[] args)throws Exception {
+    public static void main(final String... args)throws Exception {
         // Use pool of two threads
-        ExecutorService threadpool = Executors.newFixedThreadPool(2);
-        Async async = Async.newInstance().use(threadpool);
+        final ExecutorService threadpool = Executors.newFixedThreadPool(2);
+        final Async async = Async.newInstance().use(threadpool);
 
-        Request[] requests = new Request[] {
+        final Request[] requests = new Request[] {
                 Request.Get("http://www.google.com/"),
                 Request.Get("http://www.yahoo.com/"),
                 Request.Get("http://www.apache.com/"),
@@ -57,10 +57,10 @@ public class FluentAsync {
         };
 
 
-        Queue<Future<Content>> queue = new LinkedList<>();
+        final Queue<Future<Content>> queue = new LinkedList<>();
         // Execute requests asynchronously
         for (final Request request: requests) {
-            Future<Content> future = async.execute(request, new FutureCallback<Content>() {
+            final Future<Content> future = async.execute(request, new FutureCallback<Content>() {
 
                 @Override
                 public void failed(final Exception ex) {
@@ -81,10 +81,10 @@ public class FluentAsync {
         }
 
         while(!queue.isEmpty()) {
-            Future<Content> future = queue.remove();
+            final Future<Content> future = queue.remove();
             try {
                 future.get();
-            } catch (ExecutionException ex) {
+            } catch (final ExecutionException ex) {
             }
         }
         System.out.println("Done");
diff --git a/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java
similarity index 96%
rename from httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java
rename to httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java
index 2c763d1..6333c99 100644
--- a/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java
+++ b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentExecutor.java
@@ -44,8 +44,8 @@ import org.apache.hc.core5.util.Timeout;
  */
 public class FluentExecutor {
 
-    public static void main(String[] args)throws Exception {
-        Executor executor = Executor.newInstance()
+    public static void main(final String... args)throws Exception {
+        final Executor executor = Executor.newInstance()
                 .auth(new HttpHost("somehost"), "username", "password".toCharArray())
                 .auth(new HttpHost("myproxy", 8080), "username", "password".toCharArray())
                 .authPreemptive(new HttpHost("myproxy", 8080));
diff --git a/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentQuickStart.java b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentQuickStart.java
similarity index 96%
rename from httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentQuickStart.java
rename to httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentQuickStart.java
index ac38048..67d6008 100644
--- a/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentQuickStart.java
+++ b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentQuickStart.java
@@ -31,7 +31,7 @@ import org.apache.hc.client5.http.fluent.Request;
 
 public class FluentQuickStart {
 
-    public static void main(String[] args) throws Exception {
+    public static void main(final String... args) throws Exception {
         // The fluent API relieves the user from having to deal with manual
         // deallocation of system resources at the cost of having to buffer
         // response content in memory in some cases.
diff --git a/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentRequests.java b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentRequests.java
similarity index 97%
rename from httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentRequests.java
rename to httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentRequests.java
index a8d22bf..a2559f7 100644
--- a/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentRequests.java
+++ b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentRequests.java
@@ -40,7 +40,7 @@ import org.apache.hc.core5.util.Timeout;
  */
 public class FluentRequests {
 
-    public static void main(String[] args)throws Exception {
+    public static void main(final String... args)throws Exception {
         // Execute a GET with timeout settings and return response content as String.
         Request.Get("http://somehost/")
                 .connectTimeout(Timeout.ofSeconds(1))
diff --git a/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentResponseHandling.java b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentResponseHandling.java
similarity index 84%
rename from httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentResponseHandling.java
rename to httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentResponseHandling.java
index 18f9ab6..9fa5aa1 100644
--- a/httpclient5-fluent/src/examples/org/apache/hc/client5/http/examples/fluent/FluentResponseHandling.java
+++ b/httpclient5-fluent/src/test/java/org/apache/hc/client5/http/examples/fluent/FluentResponseHandling.java
@@ -51,24 +51,24 @@ import org.xml.sax.SAXException;
  */
 public class FluentResponseHandling {
 
-    public static void main(String[] args)throws Exception {
-        Document result = Request.Get("http://somehost/content")
+    public static void main(final String... args)throws Exception {
+        final Document result = Request.Get("http://somehost/content")
                 .execute().handleResponse(new HttpClientResponseHandler<Document>() {
 
             @Override
             public Document handleResponse(final ClassicHttpResponse response) throws IOException {
-                int status = response.getCode();
-                HttpEntity entity = response.getEntity();
+                final int status = response.getCode();
+                final HttpEntity entity = response.getEntity();
                 if (status >= HttpStatus.SC_REDIRECTION) {
                     throw new HttpResponseException(status, response.getReasonPhrase());
                 }
                 if (entity == null) {
                     throw new ClientProtocolException("Response contains no content");
                 }
-                DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
+                final DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();
                 try {
-                    DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
-                    ContentType contentType = ContentType.parseLenient(entity.getContentType());
+                    final DocumentBuilder docBuilder = dbfac.newDocumentBuilder();
+                    final ContentType contentType = ContentType.parseLenient(entity.getContentType());
                     if (!contentType.equals(ContentType.APPLICATION_XML)) {
                         throw new ClientProtocolException("Unexpected content type:" + contentType);
                     }
@@ -77,9 +77,9 @@ public class FluentResponseHandling {
                         charset = StandardCharsets.ISO_8859_1;
                     }
                     return docBuilder.parse(entity.getContent(), charset.name());
-                } catch (ParserConfigurationException ex) {
+                } catch (final ParserConfigurationException ex) {
                     throw new IllegalStateException(ex);
-                } catch (SAXException ex) {
+                } catch (final SAXException ex) {
                     throw new ClientProtocolException("Malformed XML document", ex);
                 }
             }
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientAuthentication.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientAuthentication.java
similarity index 91%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientAuthentication.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientAuthentication.java
index c3287d0..08278f3 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientAuthentication.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientAuthentication.java
@@ -45,18 +45,18 @@ import org.apache.hc.core5.io.CloseMode;
  */
 public class AsyncClientAuthentication {
 
-    public static void main(String[] args) throws Exception {
-        BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
+    public static void main(final String[] args) throws Exception {
+        final BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
         credsProvider.setCredentials(
                 new AuthScope("httpbin.org", 80),
                 new UsernamePasswordCredentials("user", "passwd".toCharArray()));
-        CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
+        final CloseableHttpAsyncClient httpclient = HttpAsyncClients.custom()
                 .setDefaultCredentialsProvider(credsProvider)
                 .build();
         httpclient.start();
 
         final String requestUri = "http://httpbin.org/basic-auth/user/passwd";
-        SimpleHttpRequest httpget = SimpleHttpRequests.GET.create(requestUri);
+        final SimpleHttpRequest httpget = SimpleHttpRequests.GET.create(requestUri);
 
         System.out.println("Executing request " + requestUri);
         final Future<SimpleHttpResponse> future = httpclient.execute(
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java
similarity index 100%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientConnectionEviction.java
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientCustomSSL.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientCustomSSL.java
similarity index 97%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientCustomSSL.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientCustomSSL.java
index 2a2f9de..2f1bb92 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientCustomSSL.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientCustomSSL.java
@@ -57,7 +57,7 @@ import org.apache.hc.core5.ssl.TrustStrategy;
  */
 public class AsyncClientCustomSSL {
 
-    public final static void main(final String[] args) throws Exception {
+    public static void main(final String[] args) throws Exception {
         // Trust standard CA and those trusted by our custom strategy
         final SSLContext sslcontext = SSLContexts.custom()
                 .loadTrustMaterial(new TrustStrategy() {
@@ -91,7 +91,7 @@ public class AsyncClientCustomSSL {
         final PoolingAsyncClientConnectionManager cm = PoolingAsyncClientConnectionManagerBuilder.create()
                 .setTlsStrategy(tlsStrategy)
                 .build();
-        try (CloseableHttpAsyncClient client = HttpAsyncClients.custom()
+        try (final CloseableHttpAsyncClient client = HttpAsyncClients.custom()
                 .setConnectionManager(cm)
                 .build()) {
 
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java
similarity index 100%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientFullDuplexExchange.java
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java
similarity index 100%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp1Pipelining.java
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2FullDuplexExchange.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2FullDuplexExchange.java
similarity index 100%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2FullDuplexExchange.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2FullDuplexExchange.java
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java
similarity index 100%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2Multiplexing.java
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
similarity index 100%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttp2ServerPush.java
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java
similarity index 100%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchange.java
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
similarity index 100%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientHttpExchangeStreaming.java
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java
similarity index 92%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java
index 50a19ab..e1a6d97 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientInterceptors.java
@@ -66,7 +66,7 @@ import org.apache.hc.core5.util.Timeout;
  */
 public class AsyncClientInterceptors {
 
-    public final static void main(final String[] args) throws Exception {
+    public static void main(final String[] args) throws Exception {
 
         final IOReactorConfig ioReactorConfig = IOReactorConfig.custom()
                 .setSoTimeout(Timeout.ofSeconds(5))
@@ -101,11 +101,11 @@ public class AsyncClientInterceptors {
                             final AsyncExecChain.Scope scope,
                             final AsyncExecChain chain,
                             final AsyncExecCallback asyncExecCallback) throws HttpException, IOException {
-                        Header idHeader = request.getFirstHeader("request-id");
+                        final Header idHeader = request.getFirstHeader("request-id");
                         if (idHeader != null && "13".equalsIgnoreCase(idHeader.getValue())) {
-                            HttpResponse response = new BasicHttpResponse(HttpStatus.SC_NOT_FOUND, "Oppsie");
-                            ByteBuffer content = ByteBuffer.wrap("bad luck".getBytes(StandardCharsets.US_ASCII));
-                            AsyncDataConsumer asyncDataConsumer = asyncExecCallback.handleResponse(
+                            final HttpResponse response = new BasicHttpResponse(HttpStatus.SC_NOT_FOUND, "Oppsie");
+                            final ByteBuffer content = ByteBuffer.wrap("bad luck".getBytes(StandardCharsets.US_ASCII));
+                            final AsyncDataConsumer asyncDataConsumer = asyncExecCallback.handleResponse(
                                     response,
                                     new BasicEntityDetails(content.remaining(), ContentType.TEXT_PLAIN));
                             asyncDataConsumer.consume(content);
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java
similarity index 100%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientMessageTrailers.java
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientTlsAlpn.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientTlsAlpn.java
similarity index 98%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientTlsAlpn.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientTlsAlpn.java
index 151615c..412307a 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncClientTlsAlpn.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncClientTlsAlpn.java
@@ -72,7 +72,7 @@ public class AsyncClientTlsAlpn {
         final PoolingAsyncClientConnectionManager cm = PoolingAsyncClientConnectionManagerBuilder.create()
                 .setTlsStrategy(tlsStrategy)
                 .build();
-        try (CloseableHttpAsyncClient client = HttpAsyncClients.custom()
+        try (final CloseableHttpAsyncClient client = HttpAsyncClients.custom()
                 .setVersionPolicy(HttpVersionPolicy.NEGOTIATE)
                 .setConnectionManager(cm)
                 .build()) {
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncQuickStart.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java
similarity index 92%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncQuickStart.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java
index 121398c..22c28a2 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/AsyncQuickStart.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/AsyncQuickStart.java
@@ -48,15 +48,15 @@ import org.apache.hc.core5.http.nio.AsyncRequestProducer;
 
 public class AsyncQuickStart {
 
-    public static void main(String[] args) throws Exception {
-        CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
+    public static void mainfinal (final String[] args) throws Exception {
+        final CloseableHttpAsyncClient httpclient = HttpAsyncClients.createDefault();
         try {
             // Start the client
             httpclient.start();
 
             // Execute request
             final SimpleHttpRequest request1 = SimpleHttpRequests.GET.create("http://httpbin.org/get");
-            Future<SimpleHttpResponse> future = httpclient.execute(request1, null);
+            final Future<SimpleHttpResponse> future = httpclient.execute(request1, null);
             // and wait until response is received
             final SimpleHttpResponse response1 = future.get();
             System.out.println(request1.getRequestUri() + "->" + response1.getCode());
@@ -90,8 +90,8 @@ public class AsyncQuickStart {
             // In real world one most likely would want also want to stream
             // request and response body content
             final CountDownLatch latch2 = new CountDownLatch(1);
-            AsyncRequestProducer producer3 = AsyncRequestBuilder.get("http://httpbin.org/get").build();
-            AbstractCharResponseConsumer<HttpResponse> consumer3 = new AbstractCharResponseConsumer<HttpResponse>() {
+            final AsyncRequestProducer producer3 = AsyncRequestBuilder.get("http://httpbin.org/get").build();
+            final AbstractCharResponseConsumer<HttpResponse> consumer3 = new AbstractCharResponseConsumer<HttpResponse>() {
 
                 HttpResponse response;
 
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAbortMethod.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientAbortMethod.java
similarity index 90%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAbortMethod.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientAbortMethod.java
index 9c07b16..55ab2fd 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAbortMethod.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientAbortMethod.java
@@ -37,12 +37,12 @@ import org.apache.hc.client5.http.impl.classic.HttpClients;
  */
 public class ClientAbortMethod {
 
-    public final static void main(final String[] args) throws Exception {
-        try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
+    public static void main(final String[] args) throws Exception {
+        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
             final HttpGet httpget = new HttpGet("http://httpbin.org/get");
 
             System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
-            try (CloseableHttpResponse response = httpclient.execute(httpget)) {
+            try (final CloseableHttpResponse response = httpclient.execute(httpget)) {
                 System.out.println("----------------------------------------");
                 System.out.println(response.getCode() + " " + response.getReasonPhrase());
                 // Do not feel like reading the response body
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAuthentication.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientAuthentication.java
similarity index 94%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAuthentication.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientAuthentication.java
index 3e2b89a..aa75fef 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientAuthentication.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientAuthentication.java
@@ -46,13 +46,13 @@ public class ClientAuthentication {
         credsProvider.setCredentials(
                 new AuthScope("httpbin.org", 80),
                 new UsernamePasswordCredentials("user", "passwd".toCharArray()));
-        try (CloseableHttpClient httpclient = HttpClients.custom()
+        try (final CloseableHttpClient httpclient = HttpClients.custom()
                 .setDefaultCredentialsProvider(credsProvider)
                 .build()) {
             final HttpGet httpget = new HttpGet("http://httpbin.org/basic-auth/user/passwd");
 
             System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
-            try (CloseableHttpResponse response = httpclient.execute(httpget)) {
+            try (final CloseableHttpResponse response = httpclient.execute(httpget)) {
                 System.out.println("----------------------------------------");
                 System.out.println(response.getCode() + " " + response.getReasonPhrase());
                 System.out.println(EntityUtils.toString(response.getEntity()));
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java
similarity index 94%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java
index d94064c..9117d33 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientChunkEncodedPost.java
@@ -47,7 +47,7 @@ public class ClientChunkEncodedPost {
             System.out.println("File path not given");
             System.exit(1);
         }
-        try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
+        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
             final HttpPost httppost = new HttpPost("http://httpbin.org/post");
 
             final File file = new File(args[0]);
@@ -63,7 +63,7 @@ public class ClientChunkEncodedPost {
             httppost.setEntity(reqEntity);
 
             System.out.println("Executing request " + httppost.getMethod() + " " + httppost.getUri());
-            try (CloseableHttpResponse response = httpclient.execute(httppost)) {
+            try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
                 System.out.println("----------------------------------------");
                 System.out.println(response.getCode() + " " + response.getReasonPhrase());
                 System.out.println(EntityUtils.toString(response.getEntity()));
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConfiguration.java
similarity index 98%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConfiguration.java
index 7262816..54db78e 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConfiguration.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConfiguration.java
@@ -201,7 +201,7 @@ public class ClientConfiguration {
 
         // Create an HttpClient with the given custom dependencies and configuration.
 
-        try (CloseableHttpClient httpclient = HttpClients.custom()
+        try (final CloseableHttpClient httpclient = HttpClients.custom()
                 .setConnectionManager(connManager)
                 .setDefaultCookieStore(cookieStore)
                 .setDefaultCredentialsProvider(credentialsProvider)
@@ -226,7 +226,7 @@ public class ClientConfiguration {
             context.setCredentialsProvider(credentialsProvider);
 
             System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
-            try (CloseableHttpResponse response = httpclient.execute(httpget, context)) {
+            try (final CloseableHttpResponse response = httpclient.execute(httpget, context)) {
                 System.out.println("----------------------------------------");
                 System.out.println(response.getCode() + " " + response.getReasonPhrase());
                 System.out.println(EntityUtils.toString(response.getEntity()));
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConnectionRelease.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConnectionRelease.java
similarity index 92%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConnectionRelease.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConnectionRelease.java
index cab1778..648160b 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientConnectionRelease.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientConnectionRelease.java
@@ -43,11 +43,11 @@ import org.apache.hc.core5.http.HttpEntity;
 public class ClientConnectionRelease {
 
     public final static void main(final String[] args) throws Exception {
-        try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
+        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
             final HttpGet httpget = new HttpGet("http://httpbin.org/get");
 
             System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
-            try (CloseableHttpResponse response = httpclient.execute(httpget)) {
+            try (final CloseableHttpResponse response = httpclient.execute(httpget)) {
                 System.out.println("----------------------------------------");
                 System.out.println(response.getCode() + " " + response.getReasonPhrase());
 
@@ -57,7 +57,7 @@ public class ClientConnectionRelease {
                 // If the response does not enclose an entity, there is no need
                 // to bother about connection release
                 if (entity != null) {
-                    try (InputStream inStream = entity.getContent()) {
+                    try (final InputStream inStream = entity.getContent()) {
                         inStream.read();
                         // do something useful with the response
                     } catch (final IOException ex) {
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomContext.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomContext.java
similarity index 92%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomContext.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomContext.java
index 189ee23..8ef79df 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomContext.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomContext.java
@@ -45,8 +45,8 @@ import org.apache.hc.core5.http.io.entity.EntityUtils;
  */
 public class ClientCustomContext {
 
-    public final static void main(final String[] args) throws Exception {
-        try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
+    public static void main(final String[] args) throws Exception {
+        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
             // Create a local instance of cookie store
             final CookieStore cookieStore = new BasicCookieStore();
 
@@ -59,7 +59,7 @@ public class ClientCustomContext {
             System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
 
             // Pass local context as a parameter
-            try (CloseableHttpResponse response = httpclient.execute(httpget, localContext)) {
+            try (final CloseableHttpResponse response = httpclient.execute(httpget, localContext)) {
                 System.out.println("----------------------------------------");
                 System.out.println(response.getCode() + " " + response.getReasonPhrase());
                 final List<Cookie> cookies = cookieStore.getCookies();
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomPublicSuffixList.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomPublicSuffixList.java
similarity index 94%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomPublicSuffixList.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomPublicSuffixList.java
index eed530d..2e93774 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomPublicSuffixList.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomPublicSuffixList.java
@@ -51,7 +51,7 @@ import org.apache.hc.core5.ssl.SSLContexts;
  */
 public class ClientCustomPublicSuffixList {
 
-    public final static void main(final String[] args) throws Exception {
+    public static void main(final String[] args) throws Exception {
 
         // Use PublicSuffixMatcherLoader to load public suffix list from a file,
         // resource or from an arbitrary URL
@@ -72,7 +72,7 @@ public class ClientCustomPublicSuffixList {
         final HttpClientConnectionManager cm = PoolingHttpClientConnectionManagerBuilder.create()
                 .setSSLSocketFactory(sslsf)
                 .build();
-        try (CloseableHttpClient httpclient = HttpClients.custom()
+        try (final CloseableHttpClient httpclient = HttpClients.custom()
                 .setConnectionManager(cm)
                 .setDefaultCookieSpecRegistry(cookieSpecRegistry)
                 .build()) {
@@ -81,7 +81,7 @@ public class ClientCustomPublicSuffixList {
 
             System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
 
-            try (CloseableHttpResponse response = httpclient.execute(httpget)) {
+            try (final CloseableHttpResponse response = httpclient.execute(httpget)) {
                 System.out.println("----------------------------------------");
                 System.out.println(response.getCode() + " " + response.getReasonPhrase());
                 System.out.println(EntityUtils.toString(response.getEntity()));
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomSSL.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomSSL.java
similarity index 100%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientCustomSSL.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientCustomSSL.java
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java
similarity index 92%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java
index b2a0627..338a52a 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientEvictExpiredConnections.java
@@ -44,7 +44,7 @@ public class ClientEvictExpiredConnections {
     public static void main(final String[] args) throws Exception {
         final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
         cm.setMaxTotal(100);
-        try (CloseableHttpClient httpclient = HttpClients.custom()
+        try (final CloseableHttpClient httpclient = HttpClients.custom()
                 .setConnectionManager(cm)
                 .evictExpiredConnections()
                 .evictIdleConnections(TimeValue.ofSeconds(5))
@@ -56,13 +56,12 @@ public class ClientEvictExpiredConnections {
                     "http://hc.apache.org/httpcomponents-client-ga/",
             };
 
-            for (int i = 0; i < urisToGet.length; i++) {
-                final String requestURI = urisToGet[i];
+            for (final String requestURI : urisToGet) {
                 final HttpGet request = new HttpGet(requestURI);
 
                 System.out.println("Executing request " + request.getMethod() + " " + request.getRequestUri());
 
-                try (CloseableHttpResponse response = httpclient.execute(request)) {
+                try (final CloseableHttpResponse response = httpclient.execute(request)) {
                     System.out.println("----------------------------------------");
                     System.out.println(response.getCode() + " " + response.getReasonPhrase());
                     EntityUtils.consume(response.getEntity());
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteProxy.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteProxy.java
similarity index 93%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteProxy.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteProxy.java
index 30d4751..65536bb 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteProxy.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteProxy.java
@@ -43,7 +43,7 @@ import org.apache.hc.core5.http.io.entity.EntityUtils;
 public class ClientExecuteProxy {
 
     public static void main(final String[] args)throws Exception {
-        try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
+        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
             final HttpHost target = new HttpHost("https", "httpbin.org", 443);
             final HttpHost proxy = new HttpHost("http", "127.0.0.1", 8080);
 
@@ -56,7 +56,7 @@ public class ClientExecuteProxy {
             System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +
                     " via " + proxy);
 
-            try (CloseableHttpResponse response = httpclient.execute(target, request)) {
+            try (final CloseableHttpResponse response = httpclient.execute(target, request)) {
                 System.out.println("----------------------------------------");
                 System.out.println(response.getCode() + " " + response.getReasonPhrase());
                 System.out.println(EntityUtils.toString(response.getEntity()));
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java
similarity index 95%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java
index 9cda6a3..9c1abf8 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientExecuteSOCKS.java
@@ -60,7 +60,7 @@ public class ClientExecuteSOCKS {
                 .register("http", new MyConnectionSocketFactory())
                 .build();
         final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(reg);
-        try (CloseableHttpClient httpclient = HttpClients.custom()
+        try (final CloseableHttpClient httpclient = HttpClients.custom()
                 .setConnectionManager(cm)
                 .build()) {
             final InetSocketAddress socksaddr = new InetSocketAddress("mysockshost", 1234);
@@ -72,7 +72,7 @@ public class ClientExecuteSOCKS {
 
             System.out.println("Executing request " + request.getMethod() + " " + request.getUri() +
                     " via SOCKS proxy " + socksaddr);
-            try (CloseableHttpResponse response = httpclient.execute(target, request, context)) {
+            try (final CloseableHttpResponse response = httpclient.execute(target, request, context)) {
                 System.out.println("----------------------------------------");
                 System.out.println(response.getCode() + " " + response.getReasonPhrase());
                 System.out.println(EntityUtils.toString(response.getEntity()));
@@ -97,7 +97,7 @@ public class ClientExecuteSOCKS {
                 final InetSocketAddress remoteAddress,
                 final InetSocketAddress localAddress,
                 final HttpContext context) throws IOException {
-            Socket sock;
+            final Socket sock;
             if (socket != null) {
                 sock = socket;
             } else {
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientFormLogin.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientFormLogin.java
similarity index 94%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientFormLogin.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientFormLogin.java
index b427104..4d0989d 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientFormLogin.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientFormLogin.java
@@ -48,11 +48,11 @@ public class ClientFormLogin {
 
     public static void main(final String[] args) throws Exception {
         final BasicCookieStore cookieStore = new BasicCookieStore();
-        try (CloseableHttpClient httpclient = HttpClients.custom()
+        try (final CloseableHttpClient httpclient = HttpClients.custom()
                 .setDefaultCookieStore(cookieStore)
                 .build()) {
             final HttpGet httpget = new HttpGet("https://someportal/");
-            try (CloseableHttpResponse response1 = httpclient.execute(httpget)) {
+            try (final CloseableHttpResponse response1 = httpclient.execute(httpget)) {
                 final HttpEntity entity = response1.getEntity();
 
                 System.out.println("Login form get: " + response1.getCode() + " " + response1.getReasonPhrase());
@@ -74,7 +74,7 @@ public class ClientFormLogin {
                     .addParameter("IDToken1", "username")
                     .addParameter("IDToken2", "password")
                     .build();
-            try (CloseableHttpResponse response2 = httpclient.execute(login)) {
+            try (final CloseableHttpResponse response2 = httpclient.execute(login)) {
                 final HttpEntity entity = response2.getEntity();
 
                 System.out.println("Login form get: " + response2.getCode() + " " + response2.getReasonPhrase());
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientInterceptors.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientInterceptors.java
similarity index 91%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientInterceptors.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientInterceptors.java
index 4eb6063..72dce94 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientInterceptors.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientInterceptors.java
@@ -57,8 +57,8 @@ import org.apache.hc.core5.http.protocol.HttpContext;
  */
 public class ClientInterceptors {
 
-    public final static void main(final String[] args) throws Exception {
-        try (CloseableHttpClient httpclient = HttpClients.custom()
+    public static void main(final String[] args) throws Exception {
+        try (final CloseableHttpClient httpclient = HttpClients.custom()
 
                 // Add a simple request ID to each outgoing request
 
@@ -85,9 +85,9 @@ public class ClientInterceptors {
                             final ExecChain.Scope scope,
                             final ExecChain chain) throws IOException, HttpException {
 
-                        Header idHeader = request.getFirstHeader("request-id");
+                        final Header idHeader = request.getFirstHeader("request-id");
                         if (idHeader != null && "13".equalsIgnoreCase(idHeader.getValue())) {
-                            ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_NOT_FOUND, "Oppsie");
+                            final ClassicHttpResponse response = new BasicClassicHttpResponse(HttpStatus.SC_NOT_FOUND, "Oppsie");
                             response.setEntity(new StringEntity("bad luck", ContentType.TEXT_PLAIN));
                             return response;
                         } else {
@@ -103,7 +103,7 @@ public class ClientInterceptors {
 
                 System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
 
-                try (CloseableHttpResponse response = httpclient.execute(httpget)) {
+                try (final CloseableHttpResponse response = httpclient.execute(httpget)) {
                     System.out.println("----------------------------------------");
                     System.out.println(response.getCode() + " " + response.getReasonPhrase());
                     System.out.println(EntityUtils.toString(response.getEntity()));
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultiThreadedExecution.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientMultiThreadedExecution.java
similarity index 94%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultiThreadedExecution.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientMultiThreadedExecution.java
index cf8dd70..ba26684 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultiThreadedExecution.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientMultiThreadedExecution.java
@@ -49,7 +49,7 @@ public class ClientMultiThreadedExecution {
         final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
         cm.setMaxTotal(100);
 
-        try (CloseableHttpClient httpclient = HttpClients.custom()
+        try (final CloseableHttpClient httpclient = HttpClients.custom()
                 .setConnectionManager(cm)
                 .build()) {
             // create an array of URIs to perform GETs on
@@ -67,13 +67,13 @@ public class ClientMultiThreadedExecution {
             }
 
             // start the threads
-            for (int j = 0; j < threads.length; j++) {
-                threads[j].start();
+            for (final GetThread thread : threads) {
+                thread.start();
             }
 
             // join the threads
-            for (int j = 0; j < threads.length; j++) {
-                threads[j].join();
+            for (final GetThread thread : threads) {
+                thread.join();
             }
 
         }
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java
similarity index 94%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java
index c449b19..4d5a8f3 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientMultipartFormPost.java
@@ -49,7 +49,7 @@ public class ClientMultipartFormPost {
             System.out.println("File path not given");
             System.exit(1);
         }
-        try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
+        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
             final HttpPost httppost = new HttpPost("http://localhost:8080" +
                     "/servlets-examples/servlet/RequestInfoExample");
 
@@ -65,7 +65,7 @@ public class ClientMultipartFormPost {
             httppost.setEntity(reqEntity);
 
             System.out.println("executing request " + httppost);
-            try (CloseableHttpResponse response = httpclient.execute(httppost)) {
+            try (final CloseableHttpResponse response = httpclient.execute(httppost)) {
                 System.out.println("----------------------------------------");
                 System.out.println(response);
                 final HttpEntity resEntity = response.getEntity();
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveBasicAuthentication.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientPreemptiveBasicAuthentication.java
similarity index 94%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveBasicAuthentication.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientPreemptiveBasicAuthentication.java
index de13335..e34493a 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveBasicAuthentication.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientPreemptiveBasicAuthentication.java
@@ -47,7 +47,7 @@ import org.apache.hc.core5.http.io.entity.EntityUtils;
 public class ClientPreemptiveBasicAuthentication {
 
     public static void main(final String[] args) throws Exception {
-        try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
+        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
 
             // Generate BASIC scheme object and add it to the local auth cache
             final BasicScheme basicAuth = new BasicScheme();
@@ -63,7 +63,7 @@ public class ClientPreemptiveBasicAuthentication {
 
             System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
             for (int i = 0; i < 3; i++) {
-                try (CloseableHttpResponse response = httpclient.execute(httpget, localContext)) {
+                try (final CloseableHttpResponse response = httpclient.execute(httpget, localContext)) {
                     System.out.println("----------------------------------------");
                     System.out.println(response.getCode() + " " + response.getReasonPhrase());
                     System.out.println(EntityUtils.toString(response.getEntity()));
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveDigestAuthentication.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientPreemptiveDigestAuthentication.java
similarity index 93%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveDigestAuthentication.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientPreemptiveDigestAuthentication.java
index 2f40701..e18c235 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientPreemptiveDigestAuthentication.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientPreemptiveDigestAuthentication.java
@@ -49,7 +49,7 @@ import org.apache.hc.core5.http.io.entity.EntityUtils;
 public class ClientPreemptiveDigestAuthentication {
 
     public static void main(final String[] args) throws Exception {
-        try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
+        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
 
             final HttpHost target = new HttpHost("http", "httpbin.org", 80);
 
@@ -64,7 +64,7 @@ public class ClientPreemptiveDigestAuthentication {
 
             System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
             for (int i = 0; i < 3; i++) {
-                try (CloseableHttpResponse response = httpclient.execute(target, httpget, localContext)) {
+                try (final CloseableHttpResponse response = httpclient.execute(target, httpget, localContext)) {
                     System.out.println("----------------------------------------");
                     System.out.println(response.getCode() + " " + response.getReasonPhrase());
                     EntityUtils.consume(response.getEntity());
@@ -73,7 +73,7 @@ public class ClientPreemptiveDigestAuthentication {
                     if (authExchange != null) {
                         final AuthScheme authScheme = authExchange.getAuthScheme();
                         if (authScheme instanceof DigestScheme) {
-                            DigestScheme digestScheme = (DigestScheme) authScheme;
+                            final DigestScheme digestScheme = (DigestScheme) authScheme;
                             System.out.println("Nonce: " + digestScheme.getNonce() +
                                     "; count: " + digestScheme.getNounceCount());
                         }
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientProxyAuthentication.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientProxyAuthentication.java
similarity index 95%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientProxyAuthentication.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientProxyAuthentication.java
index 18e136a..54dc420 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientProxyAuthentication.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientProxyAuthentication.java
@@ -51,7 +51,7 @@ public class ClientProxyAuthentication {
         credsProvider.setCredentials(
                 new AuthScope("httpbin.org", 80),
                 new UsernamePasswordCredentials("user", "passwd".toCharArray()));
-        try (CloseableHttpClient httpclient = HttpClients.custom()
+        try (final CloseableHttpClient httpclient = HttpClients.custom()
                 .setDefaultCredentialsProvider(credsProvider).build()) {
             final HttpHost target = new HttpHost("http", "httpbin.org", 80);
             final HttpHost proxy = new HttpHost("localhost", 8888);
@@ -65,7 +65,7 @@ public class ClientProxyAuthentication {
             System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri() +
                     " via " + proxy);
 
-            try (CloseableHttpResponse response = httpclient.execute(target, httpget)) {
+            try (final CloseableHttpResponse response = httpclient.execute(target, httpget)) {
                 System.out.println("----------------------------------------");
                 System.out.println(response.getCode() + " " + response.getReasonPhrase());
                 System.out.println(EntityUtils.toString(response.getEntity()));
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java
similarity index 98%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java
index daff646..0601c77 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientWithRequestFuture.java
@@ -57,7 +57,7 @@ public class ClientWithRequestFuture {
                 .setConnectionManager(cm)
                 .build();
         final ExecutorService execService = Executors.newFixedThreadPool(5);
-        try (FutureRequestExecutionService requestExecService = new FutureRequestExecutionService(
+        try (final FutureRequestExecutionService requestExecService = new FutureRequestExecutionService(
                 httpclient, execService)) {
             // Because things are asynchronous, you must provide a HttpClientResponseHandler
             final HttpClientResponseHandler<Boolean> handler = new HttpClientResponseHandler<Boolean>() {
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java
similarity index 95%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java
index 8dca382..1ea4d6f 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ClientWithResponseHandler.java
@@ -46,8 +46,8 @@ import org.apache.hc.core5.http.io.entity.EntityUtils;
  */
 public class ClientWithResponseHandler {
 
-    public final static void main(final String[] args) throws Exception {
-        try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
+    public static void main(final String[] args) throws Exception {
+        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
             final HttpGet httpget = new HttpGet("http://httpbin.org/get");
 
             System.out.println("Executing request " + httpget.getMethod() + " " + httpget.getUri());
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ProxyTunnelDemo.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ProxyTunnelDemo.java
similarity index 97%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ProxyTunnelDemo.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ProxyTunnelDemo.java
index b0dc51a..d71ad79 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ProxyTunnelDemo.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ProxyTunnelDemo.java
@@ -49,7 +49,7 @@ public class ProxyTunnelDemo {
         final HttpHost target = new HttpHost("www.yahoo.com", 80);
         final HttpHost proxy = new HttpHost("localhost", 8888);
         final UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("user", "pwd".toCharArray());
-        try (Socket socket = proxyClient.tunnel(proxy, target, credentials)) {
+        try (final Socket socket = proxyClient.tunnel(proxy, target, credentials)) {
             final Writer out = new OutputStreamWriter(socket.getOutputStream(), StandardCharsets.ISO_8859_1);
             out.write("GET / HTTP/1.1\r\n");
             out.write("Host: " + target.toHostString() + "\r\n");
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/QuickStart.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/QuickStart.java
similarity index 93%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/QuickStart.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/QuickStart.java
index d0522fc..e8e2e23 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/QuickStart.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/QuickStart.java
@@ -43,7 +43,7 @@ import org.apache.hc.core5.http.message.BasicNameValuePair;
 public class QuickStart {
 
     public static void main(final String[] args) throws Exception {
-        try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
+        try (final CloseableHttpClient httpclient = HttpClients.createDefault()) {
             final HttpGet httpGet = new HttpGet("http://httpbin.org/get");
             // The underlying HTTP connection is still held by the response object
             // to allow the response content to be streamed directly from the network socket.
@@ -52,7 +52,7 @@ public class QuickStart {
             // Please note that if response content is not fully consumed the underlying
             // connection cannot be safely re-used and will be shut down and discarded
             // by the connection manager.
-            try (CloseableHttpResponse response1 = httpclient.execute(httpGet)) {
+            try (final CloseableHttpResponse response1 = httpclient.execute(httpGet)) {
                 System.out.println(response1.getCode() + " " + response1.getReasonPhrase());
                 final HttpEntity entity1 = response1.getEntity();
                 // do something useful with the response body
@@ -66,7 +66,7 @@ public class QuickStart {
             nvps.add(new BasicNameValuePair("password", "secret"));
             httpPost.setEntity(new UrlEncodedFormEntity(nvps));
 
-            try (CloseableHttpResponse response2 = httpclient.execute(httpPost)) {
+            try (final CloseableHttpResponse response2 = httpclient.execute(httpPost)) {
                 System.out.println(response2.getCode() + " " + response2.getReasonPhrase());
                 final HttpEntity entity2 = response2.getEntity();
                 // do something useful with the response body
diff --git a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ReactiveClientFullDuplexExchange.java b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ReactiveClientFullDuplexExchange.java
similarity index 96%
rename from httpclient5/src/examples/org/apache/hc/client5/http/examples/ReactiveClientFullDuplexExchange.java
rename to httpclient5/src/test/java/org/apache/hc/client5/http/examples/ReactiveClientFullDuplexExchange.java
index 12e427d..2f2abde 100644
--- a/httpclient5/src/examples/org/apache/hc/client5/http/examples/ReactiveClientFullDuplexExchange.java
+++ b/httpclient5/src/test/java/org/apache/hc/client5/http/examples/ReactiveClientFullDuplexExchange.java
@@ -75,7 +75,7 @@ public class ReactiveClientFullDuplexExchange {
         client.start();
 
         final URI requestUri = new URI("http://httpbin.org/post");
-        byte[] bs = "stuff".getBytes(StandardCharsets.UTF_8);
+        final byte[] bs = "stuff".getBytes(StandardCharsets.UTF_8);
         final ReactiveEntityProducer reactiveEntityProducer = new ReactiveEntityProducer(
             Flowable.just(ByteBuffer.wrap(bs)), bs.length, ContentType.TEXT_PLAIN, null);
         final BasicRequestProducer requestProducer = new BasicRequestProducer(
@@ -86,7 +86,7 @@ public class ReactiveClientFullDuplexExchange {
         final Message<HttpResponse, Publisher<ByteBuffer>> streamingResponse = consumer.getResponseFuture().get();
 
         System.out.println(streamingResponse.getHead());
-        for (Header header : streamingResponse.getHead().getHeaders()) {
+        for (final Header header : streamingResponse.getHead().getHeaders()) {
             System.out.println(header.toString());
         }
         System.out.println();


[httpcomponents-client] 02/02: Updated release notes for HttpClient 5.0-beta4 release

Posted by ol...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

olegk pushed a commit to branch release-preparation
in repository https://gitbox.apache.org/repos/asf/httpcomponents-client.git

commit 9710652c633b15906c7eff6df6ec4e7bb204a91e
Author: Oleg Kalnichevski <ol...@apache.org>
AuthorDate: Tue Apr 2 15:32:01 2019 +0200

    Updated release notes for HttpClient 5.0-beta4 release
---
 RELEASE_NOTES.txt | 91 ++++++++++++++++++++++++++++++++++++++++++++-----------
 1 file changed, 74 insertions(+), 17 deletions(-)

diff --git a/RELEASE_NOTES.txt b/RELEASE_NOTES.txt
index 8cdc6bc..fcec1be 100644
--- a/RELEASE_NOTES.txt
+++ b/RELEASE_NOTES.txt
@@ -1,26 +1,14 @@
 Release 5.0-BETA4
 -------------------
 
-* Update Apache Commons Codec from 1.11 to 1.12
-  Contributed by Gary Gregory <ggregory at apache.org>
-
-* Update RxJava from 2.2.2 to 2.2.7
-  Contributed by Gary Gregory <ggregory at apache.org>
-
-* Update JNA from 5.0.0 to 5.2.0
-  Contributed by Gary Gregory <ggregory at apache.org>
-
-
-Release 5.0-BETA3
--------------------
-
-This BETA release adds support for advanced TLS functions (such as ALPN protocol negotiation)
-on Java 1.7 and Java 1.8 through Conscrypt TLS library and picks up the latest fixes
-and performance improvements from HttpCore.
+This BETA release picks up the latest fixes and performance improvements from HttpCore
+and addresses a number of issues found since the previous BETA release.
 
 Notable features in this release:
 
-* TLS ALPN protocol negotiation support on older JREs through Conscrypt TLS library.
+* Security improvements.
+
+* URI handling improvements.
 
 
 Notable changes and features included in the 5.0 series are:
@@ -63,6 +51,75 @@ and documentation improvements.
 Changelog:
 -------------------
 
+* HTTPCLIENT-1976: Unsafe deserialization in DefaultHttpCacheEntrySerializer.
+  Contributed by Artem Smotrakov <artem.smotrakov at gmail.com>
+
+* HTTPCLIENT-1969: Filter out weak cipher suites.
+  Contributed by Artem Smotrakov <artem.smotrakov at gmail.com>
+
+* HttpClient should not retry requests in case of ConnectionClosedException
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
+* Bug fix: Simple response consumer to discard stored content when releasing resources.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
+* Bug fix: main async request execution handlers to release the associated response consumer
+  upon exception.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
+* Update Apache Commons Codec from 1.11 to 1.12.
+  Contributed by Gary Gregory <ggregory at apache.org>
+
+* Update RxJava from 2.2.2 to 2.2.7.
+  Contributed by Gary Gregory <ggregory at apache.org>
+
+* Update JNA from 5.0.0 to 5.2.0.
+  Contributed by Gary Gregory <ggregory at apache.org>
+
+* Some well known proxies respond with Content-Length=0, when returning 304. For robustness,
+  always use the cached entity's content length, as modern browsers do.
+  Contributed by Jayson Raymond <Jayson.Raymond15 at T-Mobile.com>
+
+* HTTPCLIENT-1960: URIBuilder incorrect handling of multiple leading slashes in path component.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
+* HTTPCLIENT-1958: PoolingHttpClientConnectionManager to throw ExecutionException
+  in case of a lease operation cancellation instead of InterruptedException.
+  Contributed by Oleg Kalnichevski <olegk at apache.org>
+
+* Shutdown executorService on AbstractHttpAsyncClientBase shutdown.
+  Contributed by 吴雪山 <xueshan.wu at ndkey.com.cn>
+
+* [HTTPCLIENT-1952: Allow default User Agent to be disabled
+  Contributed by Michael Osipov <michaelo at apache.org>
+
+* Improve HttpResponseException#getMessage.
+  Contributed by Michael Osipov <michaelo at apache.org>
+
+* Better handling of http(s).proxyUser and http(s).proxyPassword
+  Contributed by Jens Borgland <jborglan at tibco.com>
+
+* Wrong argument name in PoolingAsyncClientConnectionManagerBuilder#setConnPoolPolicy results
+  with self assignment of variable.
+  Contributed by Eryk Szymanski <eszymanski at collab.net>
+
+
+
+Release 5.0-BETA3
+-------------------
+
+This BETA release adds support for advanced TLS functions (such as ALPN protocol negotiation)
+on Java 1.7 and Java 1.8 through Conscrypt TLS library and picks up the latest fixes
+and performance improvements from HttpCore.
+
+Notable features in this release:
+
+* TLS ALPN protocol negotiation support on older JREs through Conscrypt TLS library.
+
+
+Changelog:
+-------------------
+
 * Added optional dependency on conscrypt-openjdk-uber 1.4.1; support for advanced TLS functions
   (such as ALPN extension) on Java 1.7 and Java 1.8 through Conscrypt TLS library
   Contributed by Oleg Kalnichevski <olegk at apache.org>