Skip to content

Commit 7941596

Browse files
committed
GH-1152: Fix Sonar issue
1 parent bb83aa7 commit 7941596

File tree

1 file changed

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

1 file changed

+9
-4
lines changed

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,7 @@ private String getBodyContentAsString() {
121121
return SerializationUtils.deserialize(new ByteArrayInputStream(this.body), whiteListPatterns,
122122
ClassUtils.getDefaultClassLoader()).toString();
123123
}
124-
String encoding = nullProps ? null : this.messageProperties.getContentEncoding();
125-
if (encoding == null) {
126-
encoding = bodyEncoding;
127-
}
124+
String encoding = encoding(nullProps);
128125
if (MessageProperties.CONTENT_TYPE_TEXT_PLAIN.equals(contentType)
129126
|| MessageProperties.CONTENT_TYPE_JSON.equals(contentType)
130127
|| MessageProperties.CONTENT_TYPE_JSON_ALT.equals(contentType)
@@ -139,6 +136,14 @@ private String getBodyContentAsString() {
139136
return this.body.toString() + "(byte[" + this.body.length + "])"; //NOSONAR
140137
}
141138

139+
private String encoding(boolean nullProps) {
140+
String encoding = nullProps ? null : this.messageProperties.getContentEncoding();
141+
if (encoding == null) {
142+
encoding = bodyEncoding;
143+
}
144+
return encoding;
145+
}
146+
142147
@Override
143148
public int hashCode() {
144149
final int prime = 31;

0 commit comments

Comments
 (0)