* MessageEvent.getRemoteAddress() does not return null anymore
* Improved the String representation of MessageEvent implementations
This commit is contained in:
parent
17bbe5d3ee
commit
7be842be05
@ -87,7 +87,7 @@ public class DownstreamMessageEvent implements MessageEvent {
|
||||
StringUtil.stripControlCharacters(getMessage());
|
||||
} else {
|
||||
return getChannel().toString() + " WRITE: " +
|
||||
StringUtil.stripControlCharacters(getMessage()) + ", " +
|
||||
StringUtil.stripControlCharacters(getMessage()) + " to " +
|
||||
getRemoteAddress();
|
||||
}
|
||||
}
|
||||
|
@ -57,7 +57,12 @@ public class UpstreamMessageEvent implements MessageEvent {
|
||||
}
|
||||
this.channel = channel;
|
||||
this.message = message;
|
||||
this.remoteAddress = remoteAddress;
|
||||
|
||||
if (remoteAddress != null) {
|
||||
this.remoteAddress = remoteAddress;
|
||||
} else {
|
||||
this.remoteAddress = channel.getRemoteAddress();
|
||||
}
|
||||
}
|
||||
|
||||
public Channel getChannel() {
|
||||
@ -78,12 +83,13 @@ public class UpstreamMessageEvent implements MessageEvent {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (getRemoteAddress() == null) {
|
||||
// It's safe to use identity comparison in this case.
|
||||
if (getRemoteAddress() == getChannel().getRemoteAddress()) {
|
||||
return getChannel().toString() + " RECEIVED: " +
|
||||
StringUtil.stripControlCharacters(getMessage());
|
||||
} else {
|
||||
return getChannel().toString() + " RECEIVED: " +
|
||||
StringUtil.stripControlCharacters(getMessage()) + ", " +
|
||||
StringUtil.stripControlCharacters(getMessage()) + " from " +
|
||||
getRemoteAddress();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user