Skip to content

Commit 5e412de

Browse files
committed
GH-1313: Remove more unnecessary null checks
1 parent 8de660b commit 5e412de

File tree

1 file changed

+4
-8
lines changed
  • spring-amqp/src/main/java/org/springframework/amqp/core

1 file changed

+4
-8
lines changed

spring-amqp/src/main/java/org/springframework/amqp/core/Message.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -125,17 +125,13 @@ public String toString() {
125125
}
126126

127127
private String getBodyContentAsString() {
128-
if (this.body == null) {
129-
return null;
130-
}
131128
try {
132-
boolean nullProps = this.messageProperties == null;
133-
String contentType = nullProps ? null : this.messageProperties.getContentType();
129+
String contentType = this.messageProperties.getContentType();
134130
if (MessageProperties.CONTENT_TYPE_SERIALIZED_OBJECT.equals(contentType)) {
135131
return SerializationUtils.deserialize(new ByteArrayInputStream(this.body), ALLOWED_LIST_PATTERNS,
136132
ClassUtils.getDefaultClassLoader()).toString();
137133
}
138-
String encoding = encoding(nullProps);
134+
String encoding = encoding();
139135
if (MessageProperties.CONTENT_TYPE_TEXT_PLAIN.equals(contentType)
140136
|| MessageProperties.CONTENT_TYPE_JSON.equals(contentType)
141137
|| MessageProperties.CONTENT_TYPE_JSON_ALT.equals(contentType)
@@ -150,8 +146,8 @@ private String getBodyContentAsString() {
150146
return this.body.toString() + "(byte[" + this.body.length + "])"; //NOSONAR
151147
}
152148

153-
private String encoding(boolean nullProps) {
154-
String encoding = nullProps ? null : this.messageProperties.getContentEncoding();
149+
private String encoding() {
150+
String encoding = this.messageProperties.getContentEncoding();
155151
if (encoding == null) {
156152
encoding = bodyEncoding;
157153
}

0 commit comments

Comments
 (0)