diff --git a/src/main/java/org/jboss/netty/channel/DownstreamMessageEvent.java b/src/main/java/org/jboss/netty/channel/DownstreamMessageEvent.java index 77ae6774b3..8b9464db45 100644 --- a/src/main/java/org/jboss/netty/channel/DownstreamMessageEvent.java +++ b/src/main/java/org/jboss/netty/channel/DownstreamMessageEvent.java @@ -61,7 +61,11 @@ public class DownstreamMessageEvent implements MessageEvent { this.channel = channel; this.future = future; this.message = message; - this.remoteAddress = remoteAddress; + if (remoteAddress != null) { + this.remoteAddress = remoteAddress; + } else { + this.remoteAddress = channel.getRemoteAddress(); + } } public Channel getChannel() { @@ -77,11 +81,7 @@ public class DownstreamMessageEvent implements MessageEvent { } public SocketAddress getRemoteAddress() { - if (remoteAddress != null) { - return remoteAddress; - } else { - return getChannel().getRemoteAddress(); - } + return remoteAddress; } @Override diff --git a/src/main/java/org/jboss/netty/channel/UpstreamMessageEvent.java b/src/main/java/org/jboss/netty/channel/UpstreamMessageEvent.java index d0b6b4cb7c..5e64b1ccc7 100644 --- a/src/main/java/org/jboss/netty/channel/UpstreamMessageEvent.java +++ b/src/main/java/org/jboss/netty/channel/UpstreamMessageEvent.java @@ -57,7 +57,11 @@ 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() { @@ -73,11 +77,7 @@ public class UpstreamMessageEvent implements MessageEvent { } public SocketAddress getRemoteAddress() { - if (remoteAddress != null) { - return remoteAddress; - } else { - return getChannel().getRemoteAddress(); - } + return remoteAddress; } @Override