Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 11BDD200C08 for ; Thu, 12 Jan 2017 00:44:20 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 10601160B50; Wed, 11 Jan 2017 23:44:20 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 59600160B4E for ; Thu, 12 Jan 2017 00:44:19 +0100 (CET) Received: (qmail 72899 invoked by uid 500); 11 Jan 2017 23:44:18 -0000 Mailing-List: contact commits-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list commits@hc.apache.org Received: (qmail 72890 invoked by uid 99); 11 Jan 2017 23:44:18 -0000 Received: from Unknown (HELO svn01-us-west.apache.org) (209.188.14.144) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 11 Jan 2017 23:44:18 +0000 Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id DDC563A05E1 for ; Wed, 11 Jan 2017 23:44:17 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1778357 - /httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java Date: Wed, 11 Jan 2017 23:44:17 -0000 To: commits@hc.apache.org From: ggregory@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20170111234417.DDC563A05E1@svn01-us-west.apache.org> archived-at: Wed, 11 Jan 2017 23:44:20 -0000 Author: ggregory Date: Wed Jan 11 23:44:17 2017 New Revision: 1778357 URL: http://svn.apache.org/viewvc?rev=1778357&view=rev Log: Refactor magic number. Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java Modified: httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java URL: http://svn.apache.org/viewvc/httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java?rev=1778357&r1=1778356&r2=1778357&view=diff ============================================================================== --- httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java (original) +++ httpcomponents/httpcore/branches/4.4.x/httpcore/src/main/java/org/apache/http/util/EntityUtils.java Wed Jan 11 23:44:17 2017 @@ -50,6 +50,8 @@ import org.apache.http.protocol.HTTP; */ public final class EntityUtils { + private static final int DEFAULT_BUFFER_SIZE = 4096; + private EntityUtils() { } @@ -128,10 +130,10 @@ public final class EntityUtils { "HTTP entity too large to be buffered in memory"); int i = (int)entity.getContentLength(); if (i < 0) { - i = 4096; + i = DEFAULT_BUFFER_SIZE; } final ByteArrayBuffer buffer = new ByteArrayBuffer(i); - final byte[] tmp = new byte[4096]; + final byte[] tmp = new byte[DEFAULT_BUFFER_SIZE]; int l; while((l = instream.read(tmp)) != -1) { buffer.append(tmp, 0, l); @@ -205,7 +207,7 @@ public final class EntityUtils { "HTTP entity too large to be buffered in memory"); int i = (int)entity.getContentLength(); if (i < 0) { - i = 4096; + i = DEFAULT_BUFFER_SIZE; } Charset charset = null; if (contentType != null) {