Return-Path: X-Original-To: apmail-hc-commits-archive@www.apache.org Delivered-To: apmail-hc-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C483510760 for ; Wed, 9 Apr 2014 11:43:22 +0000 (UTC) Received: (qmail 62429 invoked by uid 500); 9 Apr 2014 11:43:22 -0000 Delivered-To: apmail-hc-commits-archive@hc.apache.org Received: (qmail 62129 invoked by uid 500); 9 Apr 2014 11:43:20 -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 61958 invoked by uid 99); 9 Apr 2014 11:43:18 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2014 11:43:18 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 09 Apr 2014 11:43:17 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 40CCF23889F7 for ; Wed, 9 Apr 2014 11:42:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1585944 - in /httpcomponents/httpclient/trunk/httpmime/src: main/java/org/apache/http/entity/mime/content/StringBody.java test/java/org/apache/http/entity/mime/TestMultipartContentBody.java Date: Wed, 09 Apr 2014 11:42:57 -0000 To: commits@hc.apache.org From: olegk@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140409114257.40CCF23889F7@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: olegk Date: Wed Apr 9 11:42:56 2014 New Revision: 1585944 URL: http://svn.apache.org/r1585944 Log: HTTPCLIENT-1494: null check in StringBody constructor Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java?rev=1585944&r1=1585943&r2=1585944&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java (original) +++ httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java Wed Apr 9 11:42:56 2014 @@ -152,6 +152,7 @@ public class StringBody extends Abstract */ public StringBody(final String text, final ContentType contentType) { super(contentType); + Args.notNull(text, "Text"); final Charset charset = contentType.getCharset(); this.content = text.getBytes(charset != null ? charset : Consts.ASCII); } Modified: httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java?rev=1585944&r1=1585943&r2=1585944&view=diff ============================================================================== --- httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java (original) +++ httpcomponents/httpclient/trunk/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java Wed Apr 9 11:42:56 2014 @@ -65,6 +65,16 @@ public class TestMultipartContentBody { Assert.assertEquals(MIME.ENC_8BIT, b2.getTransferEncoding()); } + @Test(expected=IllegalArgumentException.class) + public void testStringBodyInvalidConstruction1() throws Exception { + new StringBody(null, ContentType.DEFAULT_TEXT); + } + + @Test(expected=IllegalArgumentException.class) + public void testStringBodyInvalidConstruction2() throws Exception { + new StringBody("stuff", (ContentType) null); + } + @Test public void testInputStreamBody() throws Exception { final byte[] stuff = "Stuff".getBytes(Consts.ASCII);