* Updated the Javadoc of MessageEvent
* Improved how getRemoteAddress() works in DownstreamMessageEvent and UpstreamMessageEvent
This commit is contained in:
parent
7be842be05
commit
3610fa9608
@ -77,7 +77,11 @@ public class DownstreamMessageEvent implements MessageEvent {
|
||||
}
|
||||
|
||||
public SocketAddress getRemoteAddress() {
|
||||
return remoteAddress;
|
||||
if (remoteAddress != null) {
|
||||
return remoteAddress;
|
||||
} else {
|
||||
return getChannel().getRemoteAddress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -45,10 +45,7 @@ public interface MessageEvent extends ChannelEvent {
|
||||
Object getMessage();
|
||||
|
||||
/**
|
||||
* Returns the remote address.
|
||||
*
|
||||
* @return the remote address. {@code null} if the remote address is
|
||||
* same with the default remote address returned by {@link Channel#getRemoteAddress()}.
|
||||
* Returns the remote address of the message.
|
||||
*/
|
||||
SocketAddress getRemoteAddress();
|
||||
}
|
||||
|
@ -57,12 +57,7 @@ public class UpstreamMessageEvent implements MessageEvent {
|
||||
}
|
||||
this.channel = channel;
|
||||
this.message = message;
|
||||
|
||||
if (remoteAddress != null) {
|
||||
this.remoteAddress = remoteAddress;
|
||||
} else {
|
||||
this.remoteAddress = channel.getRemoteAddress();
|
||||
}
|
||||
this.remoteAddress = remoteAddress;
|
||||
}
|
||||
|
||||
public Channel getChannel() {
|
||||
@ -78,13 +73,16 @@ public class UpstreamMessageEvent implements MessageEvent {
|
||||
}
|
||||
|
||||
public SocketAddress getRemoteAddress() {
|
||||
return remoteAddress;
|
||||
if (remoteAddress != null) {
|
||||
return remoteAddress;
|
||||
} else {
|
||||
return getChannel().getRemoteAddress();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
// It's safe to use identity comparison in this case.
|
||||
if (getRemoteAddress() == getChannel().getRemoteAddress()) {
|
||||
if (getRemoteAddress() == null) {
|
||||
return getChannel().toString() + " RECEIVED: " +
|
||||
StringUtil.stripControlCharacters(getMessage());
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user