mirror of
https://github.com/apache/httpcomponents-client.git
synced 2025-02-28 05:39:07 +00:00
[HTTPCLIENT-1858] Clone some code from Log4j 2 to cache a StringBuilder
in a ThreadLocal. Update to use the StringBuilder's capacity instead of its length to measure upper bound.
This commit is contained in:
parent
fe6b90a8c6
commit
f2146cab62
@ -64,7 +64,7 @@ private static StringBuilder getStringBuilder() {
|
||||
*/
|
||||
// TODO Delete wheb Log4j's 2.9 (see #trimToMaxSize(StringBuild))
|
||||
private static void trimToMaxSize(final StringBuilder stringBuilder, final int maxSize) {
|
||||
if (stringBuilder != null && stringBuilder.length() > maxSize) {
|
||||
if (stringBuilder != null && stringBuilder.capacity() > maxSize) {
|
||||
stringBuilder.setLength(maxSize);
|
||||
stringBuilder.trimToSize();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user