From 5e412de9b1fc4e2a9ea19cd585e0e21ce260594f Mon Sep 17 00:00:00 2001 From: Gary Russell Date: Tue, 30 Mar 2021 12:14:09 -0400 Subject: [PATCH] GH-1313: Remove more unnecessary null checks --- .../java/org/springframework/amqp/core/Message.java | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/spring-amqp/src/main/java/org/springframework/amqp/core/Message.java b/spring-amqp/src/main/java/org/springframework/amqp/core/Message.java index a3d8abc6..15e9c6c7 100644 --- a/spring-amqp/src/main/java/org/springframework/amqp/core/Message.java +++ b/spring-amqp/src/main/java/org/springframework/amqp/core/Message.java @@ -125,17 +125,13 @@ public class Message implements Serializable { } private String getBodyContentAsString() { - if (this.body == null) { - return null; - } try { - boolean nullProps = this.messageProperties == null; - String contentType = nullProps ? null : this.messageProperties.getContentType(); + String contentType = this.messageProperties.getContentType(); if (MessageProperties.CONTENT_TYPE_SERIALIZED_OBJECT.equals(contentType)) { return SerializationUtils.deserialize(new ByteArrayInputStream(this.body), ALLOWED_LIST_PATTERNS, ClassUtils.getDefaultClassLoader()).toString(); } - String encoding = encoding(nullProps); + String encoding = encoding(); if (MessageProperties.CONTENT_TYPE_TEXT_PLAIN.equals(contentType) || MessageProperties.CONTENT_TYPE_JSON.equals(contentType) || MessageProperties.CONTENT_TYPE_JSON_ALT.equals(contentType) @@ -150,8 +146,8 @@ public class Message implements Serializable { return this.body.toString() + "(byte[" + this.body.length + "])"; //NOSONAR } - private String encoding(boolean nullProps) { - String encoding = nullProps ? null : this.messageProperties.getContentEncoding(); + private String encoding() { + String encoding = this.messageProperties.getContentEncoding(); if (encoding == null) { encoding = bodyEncoding; }