From 4f5d4b0d7eab9db5a3034cb883b4f853282bebf7 Mon Sep 17 00:00:00 2001 From: Sebastian Bazley Date: Tue, 21 Dec 2010 21:43:56 +0000 Subject: [PATCH] Remove unnecessary null checks for mimeType and TransferEncoding git-svn-id: https://svn.apache.org/repos/asf/httpcomponents/httpclient/trunk@1051664 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/http/entity/mime/FormBodyPart.java | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java b/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java index fbf120291..d892a675d 100644 --- a/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java +++ b/httpmime/src/main/java/org/apache/http/entity/mime/FormBodyPart.java @@ -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 } }