You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by ol...@apache.org on 2014/04/09 13:42:23 UTC
svn commit: r1585943 - in
/httpcomponents/httpclient/branches/4.3.x/httpmime/src:
main/java/org/apache/http/entity/mime/content/StringBody.java
test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
Author: olegk
Date: Wed Apr 9 11:42:23 2014
New Revision: 1585943
URL: http://svn.apache.org/r1585943
Log:
HTTPCLIENT-1494: null check in StringBody constructor
Modified:
httpcomponents/httpclient/branches/4.3.x/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
httpcomponents/httpclient/branches/4.3.x/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
Modified: httpcomponents/httpclient/branches/4.3.x/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java?rev=1585943&r1=1585942&r2=1585943&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpmime/src/main/java/org/apache/http/entity/mime/content/StringBody.java Wed Apr 9 11:42:23 2014
@@ -153,6 +153,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();
final String csname = charset != null ? charset.name() : Consts.ASCII.name();
try {
Modified: httpcomponents/httpclient/branches/4.3.x/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/branches/4.3.x/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java?rev=1585943&r1=1585942&r2=1585943&view=diff
==============================================================================
--- httpcomponents/httpclient/branches/4.3.x/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java (original)
+++ httpcomponents/httpclient/branches/4.3.x/httpmime/src/test/java/org/apache/http/entity/mime/TestMultipartContentBody.java Wed Apr 9 11:42:23 2014
@@ -64,6 +64,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("US-ASCII");