Minor Improvement:

* Add final to variable
* Use 'StringBuilder' instead 'StringBuffer'
* Concatenate with append instead
* Use Standard Charset object
diff --git a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFlag.java b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFlag.java
index 7a8b2f9..9e480fb 100644
--- a/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFlag.java
+++ b/httpcore5-h2/src/main/java/org/apache/hc/core5/http2/frame/FrameFlag.java
@@ -39,7 +39,7 @@
     PADDED        (0x08),
     PRIORITY      (0x20);
 
-    int value;
+    final int value;
 
     FrameFlag(final int value) {
         this.value = value;
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/ResultFormatter.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/ResultFormatter.java
index 8412caa..557e136 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/ResultFormatter.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/benchmark/ResultFormatter.java
@@ -36,9 +36,9 @@
         // Do not allow utility class to be instantiated.
     }
 
-    static NumberFormat nf2 = NumberFormat.getInstance(Locale.ROOT);
-    static NumberFormat nf3 = NumberFormat.getInstance(Locale.ROOT);
-    static NumberFormat nf6 = NumberFormat.getInstance(Locale.ROOT);
+    static final NumberFormat nf2 = NumberFormat.getInstance(Locale.ROOT);
+    static final NumberFormat nf3 = NumberFormat.getInstance(Locale.ROOT);
+    static final NumberFormat nf6 = NumberFormat.getInstance(Locale.ROOT);
 
     static {
         nf2.setMaximumFractionDigits(2);
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/SocksProxy.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/SocksProxy.java
index 40a17a3..ee3c111 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/SocksProxy.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/SocksProxy.java
@@ -129,7 +129,7 @@
                             break;
                         case ATYP_DOMAINNAME:
                             final int length = input.readUnsignedByte();
-                            final StringBuffer domainname = new StringBuffer();
+                            final StringBuilder domainname = new StringBuilder();
                             for (int i = 0; i < length; i++) {
                                 domainname.append((char) input.readUnsignedByte());
                             }
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClassicTestClientAdapter.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClassicTestClientAdapter.java
index 27bc929..1c4b097 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClassicTestClientAdapter.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/framework/ClassicTestClientAdapter.java
@@ -95,7 +95,7 @@
 
             // append each parm to the query
             for (final Entry<String, String> parm : queryMap.entrySet()) {
-                newQuery.append("&" + parm.getKey() + "=" + parm.getValue());
+                newQuery.append("&").append(parm.getKey()).append("=").append(parm.getValue());
             }
             // create a uri with the new query.
             uri = new URI(
diff --git a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/reactive/ReactiveTestUtils.java b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/reactive/ReactiveTestUtils.java
index 6a6bed3..541d7b1 100644
--- a/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/reactive/ReactiveTestUtils.java
+++ b/httpcore5-testing/src/main/java/org/apache/hc/core5/testing/reactive/ReactiveTestUtils.java
@@ -86,9 +86,9 @@
             final AtomicReference<String> hash
     ) {
         return Flowable.generate(new Consumer<Emitter<ByteBuffer>>() {
-            Random random = new Random(length); // Use the length as the random seed for easy reproducibility
+            final Random random = new Random(length); // Use the length as the random seed for easy reproducibility
             long bytesEmitted = 0;
-            MessageDigest md = newMessageDigest();
+            final MessageDigest md = newMessageDigest();
 
             @Override
             public void accept(final Emitter<ByteBuffer> emitter) {
diff --git a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicIntegrationTest.java b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicIntegrationTest.java
index 7e2e507..f843485 100644
--- a/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicIntegrationTest.java
+++ b/httpcore5-testing/src/test/java/org/apache/hc/core5/testing/classic/ClassicIntegrationTest.java
@@ -557,7 +557,7 @@
 
         public RepeatingEntity(final String content, final Charset charset, final int n, final boolean chunked) {
             super(ContentType.TEXT_PLAIN.withCharset(charset), null, chunked);
-            final Charset cs = charset != null ? charset : Charset.forName("US-ASCII");
+            final Charset cs = charset != null ? charset : StandardCharsets.US_ASCII;
             this.raw = content.getBytes(cs);
             this.n = n;
         }
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/util/TextUtils.java b/httpcore5/src/main/java/org/apache/hc/core5/util/TextUtils.java
index 47c4aa8..645783d 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/util/TextUtils.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/util/TextUtils.java
@@ -80,7 +80,7 @@
         if (bytes == null) {
             return null;
         }
-        final StringBuffer buffer = new StringBuffer();
+        final StringBuilder buffer = new StringBuilder();
         for (int i = 0; i < bytes.length; i++) {
             final byte b = bytes[i];
             if (b < 16) {
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/NameValuePairListMatcher.java b/httpcore5/src/test/java/org/apache/hc/core5/http/NameValuePairListMatcher.java
index 7ecf449..16c804d 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/NameValuePairListMatcher.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/NameValuePairListMatcher.java
@@ -38,7 +38,7 @@
 
 public class NameValuePairListMatcher extends BaseMatcher<List<NameValuePair>> {
 
-    private List<? extends NameValuePair> nvps;
+    private final List<? extends NameValuePair> nvps;
 
     public NameValuePairListMatcher(final List<? extends NameValuePair> nvps) {
         this.nvps = nvps;
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java b/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java
index e1348d9..c419df8 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/TestContentType.java
@@ -27,7 +27,6 @@
 
 package org.apache.hc.core5.http;
 
-import java.nio.charset.Charset;
 import java.nio.charset.StandardCharsets;
 
 import org.apache.hc.core5.http.message.BasicNameValuePair;
@@ -54,7 +53,7 @@
         Assert.assertEquals("text/plain", contentType.getMimeType());
         Assert.assertEquals(StandardCharsets.US_ASCII, contentType.getCharset());
         Assert.assertEquals("text/plain; charset=US-ASCII", contentType.toString());
-        contentType = contentType.withCharset(Charset.forName("UTF-8"));
+        contentType = contentType.withCharset(StandardCharsets.UTF_8);
         Assert.assertEquals("text/plain", contentType.getMimeType());
         Assert.assertEquals("UTF-8", contentType.getCharset().name());
         Assert.assertEquals("text/plain; charset=UTF-8", contentType.toString());
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpExceptions.java b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpExceptions.java
index 5de7b1c..30e671d 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpExceptions.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/TestHttpExceptions.java
@@ -36,7 +36,7 @@
 public class TestHttpExceptions {
 
     private static final String CLEAN_MESSAGE = "[0x00]Hello[0x06][0x07][0x08][0x09][0x0a][0x0b][0x0c][0x0d][0x0e][0x0f]World";
-    private static String nonPrintableMessage = String.valueOf(
+    private static final String nonPrintableMessage = String.valueOf(
             new char[] { 1, 'H', 'e', 'l', 'l', 'o', 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 'W', 'o', 'r', 'l', 'd' });
 
     @Test
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/examples/ClassicReverseProxyExample.java b/httpcore5/src/test/java/org/apache/hc/core5/http/examples/ClassicReverseProxyExample.java
index da8ce03..94ccf2b 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/examples/ClassicReverseProxyExample.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/examples/ClassicReverseProxyExample.java
@@ -108,14 +108,14 @@
                     @Override
                     public void onLease(final HttpHost route, final ConnPoolStats<HttpHost> connPoolStats) {
                         final StringBuilder buf = new StringBuilder();
-                        buf.append("[proxy->origin] " + Thread.currentThread()  + " connection leased ").append(route);
+                        buf.append("[proxy->origin] ").append(Thread.currentThread()).append(" connection leased ").append(route);
                         System.out.println(buf);
                     }
 
                     @Override
                     public void onRelease(final HttpHost route, final ConnPoolStats<HttpHost> connPoolStats) {
                         final StringBuilder buf = new StringBuilder();
-                        buf.append("[proxy->origin] " + Thread.currentThread()  + " connection released ").append(route);
+                        buf.append("[proxy->origin] ").append(Thread.currentThread()).append(" connection released ").append(route);
                         final PoolStats totals = connPoolStats.getTotalStats();
                         buf.append("; total kept alive: ").append(totals.getAvailable()).append("; ");
                         buf.append("total allocated: ").append(totals.getLeased() + totals.getAvailable());
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java
index e3aab55..448ff1d 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestChunkCoding.java
@@ -310,16 +310,10 @@
 
         final SessionInputBuffer inBuffer2 = new SessionInputBufferImpl(16, 10);
         final ByteArrayInputStream inputStream2 = new ByteArrayInputStream(s.getBytes(StandardCharsets.ISO_8859_1));
-        final ChunkedInputStream in2 = new ChunkedInputStream(inBuffer2, inputStream2);
-        try {
+        try (ChunkedInputStream in2 = new ChunkedInputStream(inBuffer2, inputStream2)) {
             in2.read(buffer);
             Assert.fail("MessageConstraintException expected");
         } catch (final MessageConstraintException ex) {
-        } finally {
-            try {
-                in2.close();
-            } catch (final MessageConstraintException ex) {
-            }
         }
     }
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
index 45ddbee..0cf8932 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestDefaultBHttpServerConnection.java
@@ -218,7 +218,7 @@
         conn.flush();
 
         Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
-        final String s = new String(outStream.toByteArray(), "ASCII");
+        final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
         Assert.assertEquals("HTTP/1.1 200 OK\r\nUser-Agent: test\r\n\r\n", s);
     }
 
@@ -237,7 +237,7 @@
         conn.flush();
 
         Assert.assertEquals(0, conn.getEndpointDetails().getResponseCount());
-        final String s = new String(outStream.toByteArray(), "ASCII");
+        final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
         Assert.assertEquals("HTTP/1.1 100 Go on\r\n\r\n", s);
     }
 
@@ -260,7 +260,7 @@
         conn.flush();
 
         Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
-        final String s = new String(outStream.toByteArray(), "ASCII");
+        final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
         Assert.assertEquals("HTTP/1.1 200 OK\r\nServer: test\r\nContent-Length: 3\r\n\r\n123", s);
     }
 
@@ -283,7 +283,7 @@
         conn.flush();
 
         Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
-        final String s = new String(outStream.toByteArray(), "ASCII");
+        final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
         Assert.assertEquals("HTTP/1.1 200 OK\r\nServer: test\r\nTransfer-Encoding: " +
                 "chunked\r\n\r\n3\r\n123\r\n0\r\n\r\n", s);
     }
@@ -324,7 +324,7 @@
         conn.flush();
 
         Assert.assertEquals(1, conn.getEndpointDetails().getResponseCount());
-        final String s = new String(outStream.toByteArray(), "ASCII");
+        final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
         Assert.assertEquals("HTTP/1.1 200 OK\r\nServer: test\r\n\r\n", s);
     }
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
index 5b48379..140f5d7 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TestSessionInOutBuffers.java
@@ -624,7 +624,7 @@
         chbuffer.append(s);
         outbuffer.writeLine(chbuffer, outputStream);
         outbuffer.flush(outputStream);
-        final String result = new String(outputStream.toByteArray(), "ISO-8859-1");
+        final String result = new String(outputStream.toByteArray(), StandardCharsets.ISO_8859_1);
         Assert.assertEquals("This text contains a circumflex ? !!!\r\n", result);
     }
 
@@ -640,7 +640,7 @@
         chbuffer.append(s);
         outbuffer.writeLine(chbuffer, outputStream);
         outbuffer.flush(outputStream);
-        final String result = new String(outputStream.toByteArray(), "ISO-8859-1");
+        final String result = new String(outputStream.toByteArray(), StandardCharsets.ISO_8859_1);
         Assert.assertEquals("This text contains a circumflex  !!!\r\n", result);
     }
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
index 97bdf49..ba87dc5 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/io/TimeoutByteArrayInputStream.java
@@ -40,7 +40,7 @@
     private final byte[] buf;
 
     private int pos;
-    protected int count;
+    protected final int count;
 
     public TimeoutByteArrayInputStream(final byte[] buf, final int off, final int len) {
         super();
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java
index 175bfda..3381713 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/http/impl/nio/TestSessionInOutBuffers.java
@@ -198,7 +198,7 @@
         final WritableByteChannel outChannel = newChannel(outStream);
         outbuf.flush(outChannel);
 
-        final String s = new String(outStream.toByteArray(), "US-ASCII");
+        final String s = new String(outStream.toByteArray(), StandardCharsets.US_ASCII);
         Assert.assertEquals("One\r\nTwo\r\nThree\r\nFour\r\n", s);
     }
 
@@ -597,7 +597,7 @@
         outbuf.writeLine(chbuffer);
         outbuf.flush(channel);
 
-        final String result = new String(baos.toByteArray(), "US-ASCII");
+        final String result = new String(baos.toByteArray(), StandardCharsets.US_ASCII);
         Assert.assertEquals("This text contains a circumflex !!!\r\n", result);
     }
 
@@ -615,7 +615,7 @@
         outbuf.writeLine(chbuffer);
         outbuf.flush(channel);
 
-        final String result = new String(baos.toByteArray(), "US-ASCII");
+        final String result = new String(baos.toByteArray(), StandardCharsets.US_ASCII);
         Assert.assertEquals("This text contains a circumflex ? !!!\r\n", result);
     }
 
diff --git a/httpcore5/src/test/java/org/apache/hc/core5/util/TestByteArrayBuffer.java b/httpcore5/src/test/java/org/apache/hc/core5/util/TestByteArrayBuffer.java
index 6d8d6f5..920cae8 100644
--- a/httpcore5/src/test/java/org/apache/hc/core5/util/TestByteArrayBuffer.java
+++ b/httpcore5/src/test/java/org/apache/hc/core5/util/TestByteArrayBuffer.java
@@ -294,7 +294,7 @@
         buffer.append(b1, 0, b1.length);
         buffer.append(b2, 0, b2.length);
 
-        Assert.assertEquals(s1 + s2, new String(buffer.toByteArray(), "US-ASCII"));
+        Assert.assertEquals(s1 + s2, new String(buffer.toByteArray(), StandardCharsets.US_ASCII));
     }
 
     @Test