You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by gg...@apache.org on 2017/07/13 01:21:13 UTC

httpcomponents-client git commit: [HTTPCLIENT-1858] Simplify and no longer use a system property to override default max size.

Repository: httpcomponents-client
Updated Branches:
  refs/heads/HTTPCLIENT-1858 375808a3a -> 712712339


[HTTPCLIENT-1858] Simplify and no longer use a system property to
override default max size.

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

Branch: refs/heads/HTTPCLIENT-1858
Commit: 71271233909bac9ff9aaa677fc15fb0160462647
Parents: 375808a
Author: Gary Gregory <gg...@apache.org>
Authored: Wed Jul 12 18:21:11 2017 -0700
Committer: Gary Gregory <gg...@apache.org>
Committed: Wed Jul 12 18:21:11 2017 -0700

----------------------------------------------------------------------
 .../hc/client5/http/impl/logging/Wire.java      | 24 ++++----------------
 1 file changed, 4 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-client/blob/71271233/httpclient5/src/main/java/org/apache/hc/client5/http/impl/logging/Wire.java
----------------------------------------------------------------------
diff --git a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/logging/Wire.java b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/logging/Wire.java
index 5c0cadf..e6b09b1 100644
--- a/httpclient5/src/main/java/org/apache/hc/client5/http/impl/logging/Wire.java
+++ b/httpclient5/src/main/java/org/apache/hc/client5/http/impl/logging/Wire.java
@@ -34,20 +34,8 @@ import org.apache.logging.log4j.Logger;
 
 class Wire {
 
-    /**
-     * Default length for new StringBuilder instances: {@value} .
-     */
-    private static final int DEFAULT_STRING_BUILDER_SIZE = 1024;
+    private static final int MAX_STRING_BUILDER_SIZE = 2048;
 
-    // TODO We should really pick this up from the ctor, and the client config? Or that too low level a detail?
-    private static final int MAX_STRING_BUILDER_SIZE = Math.max(DEFAULT_STRING_BUILDER_SIZE,
-            size("hc.client.wire.maxStringBuilderSize", 2 * 1024));
-
-    private static int size(final String property, final int defaultValue) {
-        final String str = System.getProperty(property);
-        return str == null ? defaultValue : Integer.parseInt(str);
-    }
-    
     private static final ThreadLocal<StringBuilder> threadLocal = new ThreadLocal<>();
 
     /**
@@ -58,19 +46,15 @@ class Wire {
     private static StringBuilder getStringBuilder() {
         StringBuilder result = threadLocal.get();
         if (result == null) {
-            result = new StringBuilder(DEFAULT_STRING_BUILDER_SIZE);
+            result = new StringBuilder(MAX_STRING_BUILDER_SIZE);
             threadLocal.set(result);
         }
-        trimToMaxSize(result);
+        // TODO Delegate to Log4j's 2.9 StringBuilds.trimToMaxSize() when it is released.
+        trimToMaxSize(result, MAX_STRING_BUILDER_SIZE);
         result.setLength(0);
         return result;
     }
 
-    private static void trimToMaxSize(final StringBuilder stringBuilder) {
-        // TODO Delegate to Log4j's 2.9 StringBuilds.trimToMaxSize() when it is released.
-        trimToMaxSize(stringBuilder, MAX_STRING_BUILDER_SIZE);
-    }
-    
     /**
      * Ensures that the char[] array of the specified StringBuilder does not exceed the specified number of characters.
      * This method is useful to ensure that excessively long char[] arrays are not kept in memory forever.