Do not use finally to propagate events in AbstractRemoteAddressFilter

Motivation:

We don't really need to propagate an event when handling the event fails.

Modifications:

Do not use finally block in AbstractRemoteAddressFilter

Result:

AbstractRemoteaddressFilter does not forward an event in case of failure.
This commit is contained in:
Trustin Lee 2014-03-12 16:17:40 +09:00
parent fddbde7df2
commit 614dc72b56

View File

@ -39,20 +39,15 @@ public abstract class AbstractRemoteAddressFilter<T extends SocketAddress> exten
@Override
public void channelRegistered(ChannelHandlerContext ctx) throws Exception {
try {
handleNewChannel(ctx);
} finally {
ctx.fireChannelRegistered();
}
handleNewChannel(ctx);
ctx.fireChannelRegistered();
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
try {
if (!handleNewChannel(ctx)) {
throw new IllegalStateException("cannot determine to accept or reject a channel: " + ctx.channel());
}
} finally {
if (!handleNewChannel(ctx)) {
throw new IllegalStateException("cannot determine to accept or reject a channel: " + ctx.channel());
} else {
ctx.fireChannelActive();
}
}