Related issue: NETTY-180 Channel.getRemoteAddress() can return null for a received MessageEvent when ExecutionHandler is in the pipeline.

* AbstractChannel.toString() does not use isConnected() or isBound() because it can lead to inconsistent string representation when ExecutionHandler is in the pipeline.
This commit is contained in:
Trustin Lee 2009-06-23 07:20:57 +00:00
parent 27ef64f549
commit 8448188706

View File

@ -257,20 +257,22 @@ public abstract class AbstractChannel implements Channel {
buf.append("[id: 0x");
buf.append(getIdString());
if (connected) {
SocketAddress localAddress = getLocalAddress();
SocketAddress remoteAddress = getRemoteAddress();
if (remoteAddress != null) {
buf.append(", ");
if (getParent() == null) {
buf.append(getLocalAddress());
buf.append(localAddress);
buf.append(" => ");
buf.append(getRemoteAddress());
buf.append(remoteAddress);
} else {
buf.append(getRemoteAddress());
buf.append(remoteAddress);
buf.append(" => ");
buf.append(getLocalAddress());
buf.append(localAddress);
}
} else if (isBound()) {
} else if (localAddress != null) {
buf.append(", ");
buf.append(getLocalAddress());
buf.append(localAddress);
}
buf.append(']');