fix the issue netty#2944 in 4.0 #4809

Motivation:

fix the issue netty#2944

Modifications:

(1) use - instead of =>, use ! instead of :> due to the connection is bidirectional. What's more, toString() method don't know the direction or there is no need to know the direction when only log channel information.
(2) add L: before local address and R: before remote address.

Result:

after the fix, toString() won't confuse the user.
This commit is contained in:
fu.jian 2016-02-02 10:46:18 +08:00 committed by Norman Maurer
parent 998b8a8cb9
commit dd2f9f9acb

View File

@ -340,18 +340,10 @@ public abstract class AbstractChannel extends DefaultAttributeMap implements Cha
SocketAddress remoteAddr = remoteAddress();
SocketAddress localAddr = localAddress();
if (remoteAddr != null) {
SocketAddress srcAddr;
SocketAddress dstAddr;
if (parent == null) {
srcAddr = localAddr;
dstAddr = remoteAddr;
} else {
srcAddr = remoteAddr;
dstAddr = localAddr;
}
strVal = String.format("[id: 0x%08x, %s %s %s]", (int) hashCode, srcAddr, active? "=>" : ":>", dstAddr);
String activeNotation = active? "-" : "!";
strVal = String.format("[id: 0x%08x, L:%s %s R:%s]", (int) hashCode, localAddr, activeNotation, remoteAddr);
} else if (localAddr != null) {
strVal = String.format("[id: 0x%08x, %s]", (int) hashCode, localAddr);
strVal = String.format("[id: 0x%08x, L:%s]", (int) hashCode, localAddr);
} else {
strVal = String.format("[id: 0x%08x]", (int) hashCode);
}