hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject httpcomponents-core git commit: SSLBufferManagement can be overridden for custom buffer pooling
Date Sat, 05 Aug 2017 14:59:43 GMT
Repository: httpcomponents-core
Updated Branches:
  refs/heads/master 479ad3486 -> c7d4ee28b


SSLBufferManagement can be overridden for custom buffer pooling

Some applications maintain ByteBuffer pools already, reusing
already pooled buffers with the client can reduce memory churn.

Additionally, using native crypto JSSE implementations (such as
wildfly-openssl or conscrypt/boringssl) requires the use of direct
ByteBuffers.

Closes PR #46


Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/c7d4ee28
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/c7d4ee28
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/c7d4ee28

Branch: refs/heads/master
Commit: c7d4ee28b2ff1c9c5c717265ce267f74fab93f67
Parents: 479ad34
Author: Carter Kozak <ckozak@palantir.com>
Authored: Fri Aug 4 14:30:30 2017 -0400
Committer: Oleg Kalnichevski <olegk@apache.org>
Committed: Sat Aug 5 16:58:45 2017 +0200

----------------------------------------------------------------------
 .../core5/reactor/ssl/SSLBufferManagement.java  | 31 +++++++++++++++++---
 1 file changed, 27 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/c7d4ee28/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagement.java
----------------------------------------------------------------------
diff --git a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagement.java
b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagement.java
index 1a72c77..df1e4ff 100644
--- a/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagement.java
+++ b/httpcore5/src/main/java/org/apache/hc/core5/reactor/ssl/SSLBufferManagement.java
@@ -34,13 +34,27 @@ import org.apache.hc.core5.util.Args;
 /**
  * @since 5.0
  */
-public enum SSLBufferManagement {
+public abstract class SSLBufferManagement {
 
-    STATIC,
-    DYNAMIC;
+    public static final SSLBufferManagement STATIC = new StaticSSLBufferManagement();
+    public static final SSLBufferManagement DYNAMIC = new DynamicSSLBufferManagement();
+
+    public abstract SSLBuffer create(int size);
 
     static SSLBuffer create(final SSLBufferManagement mode, final int size) {
-        return mode == DYNAMIC ? new DynamicBuffer(size) : new StaticBuffer(size);
+        if (mode == null) {
+            return STATIC.create(size);
+        }
+        return mode.create(size);
+    }
+
+    private static final class StaticSSLBufferManagement extends SSLBufferManagement {
+
+        @Override
+        public SSLBuffer create(final int size) {
+            return new StaticBuffer(size);
+        }
+
     }
 
     private static final class StaticBuffer implements SSLBuffer {
@@ -74,6 +88,15 @@ public enum SSLBufferManagement {
 
     }
 
+    private static final class DynamicSSLBufferManagement extends SSLBufferManagement {
+
+        @Override
+        public SSLBuffer create(final int size) {
+            return new DynamicBuffer(size);
+        }
+
+    }
+
     private static final class DynamicBuffer implements SSLBuffer {
 
         private ByteBuffer wrapped;


Mime
View raw message