Skip to content

Commit d2eff4e

Browse files
committed
Improve GenericMessage.toString()
Restore pringing the payload first and headers second as it has been in SI but also handle specifically the case where the body is a byte array to minimize unnecessary "noise" that causes otherwise for STOMP msgs.
1 parent 61d1354 commit d2eff4e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

spring-messaging/src/main/java/org/springframework/messaging/support/GenericMessage.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,15 @@ public T getPayload() {
8282
}
8383

8484
public String toString() {
85-
StringBuilder sb = new StringBuilder("[Headers=" + this.headers + "]");
86-
sb.append("[Payload ").append(this.payload.getClass().getSimpleName());
87-
sb.append(" content=").append(this.payload).append("]");
85+
StringBuilder sb = new StringBuilder();
86+
if (byte[].class.equals(this.payload.getClass())) {
87+
sb.append("[Payload byte[").append(((byte[]) this.payload).length).append("]]");
88+
}
89+
else {
90+
sb.append("[Payload ").append(this.payload.getClass().getSimpleName());
91+
sb.append(" content=").append(this.payload).append("]");
92+
}
93+
sb.append("[Headers=" + this.headers + "]");
8894
return sb.toString();
8995
}
9096

0 commit comments

Comments
 (0)