Skip to content

Commit d99dac0

Browse files
committed
refactor: 优化tcp报文打印
1 parent 472e1dc commit d99dac0

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

jetlinks-components/network-component/tcp-component/src/main/java/org/jetlinks/community/network/tcp/TcpMessage.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,9 @@ public class TcpMessage implements EncodedMessage {
4444

4545
@Override
4646
public String toString() {
47-
StringBuilder builder = new StringBuilder();
48-
49-
if (ByteBufUtil.isText(payload, StandardCharsets.UTF_8)) {
50-
builder.append(payloadAsString());
51-
} else {
52-
ByteBufUtil.appendPrettyHexDump(builder, payload);
47+
if (payload == null || !payload.isReadable()) {
48+
return "<released>";
5349
}
54-
55-
return builder.toString();
50+
return ByteBufUtil.prettyHexDump(payload);
5651
}
5752
}

0 commit comments

Comments
 (0)