You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hc.apache.org by se...@apache.org on 2010/12/21 22:43:57 UTC

svn commit: r1051664 - /httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java

Author: sebb
Date: Tue Dec 21 21:43:56 2010
New Revision: 1051664

URL: http://svn.apache.org/viewvc?rev=1051664&view=rev
Log:
Remove unnecessary null checks for mimeType and TransferEncoding

Modified:
    httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java

Modified: httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java
URL: http://svn.apache.org/viewvc/httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java?rev=1051664&r1=1051663&r2=1051664&view=diff
==============================================================================
--- httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java (original)
+++ httpcomponents/httpclient/trunk/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java Tue Dec 21 21:43:56 2010
@@ -93,21 +93,17 @@ public class FormBodyPart {
     }
 
     protected void generateContentType(final ContentBody body) {
-        if (body.getMimeType() != null) {
-            StringBuilder buffer = new StringBuilder();
-            buffer.append(body.getMimeType());
-            if (body.getCharset() != null) {
-                buffer.append("; charset=");
-                buffer.append(body.getCharset());
-            }
-            addField(MIME.CONTENT_TYPE, buffer.toString());
+        StringBuilder buffer = new StringBuilder();
+        buffer.append(body.getMimeType()); // MimeType cannot be null
+        if (body.getCharset() != null) { // charset may legitimately be null
+            buffer.append("; charset=");
+            buffer.append(body.getCharset());
         }
+        addField(MIME.CONTENT_TYPE, buffer.toString());
     }
 
     protected void generateTransferEncoding(final ContentBody body) {
-        if (body.getTransferEncoding() != null) {
-            addField(MIME.CONTENT_TRANSFER_ENC, body.getTransferEncoding());
-        }
+        addField(MIME.CONTENT_TRANSFER_ENC, body.getTransferEncoding()); // TE cannot be null
     }
 
 }