Move exceptionCaught(..) back to ChannelHandler. Related to [#1118]

This commit is contained in:
Norman Maurer 2013-03-05 07:34:34 +01:00
parent faaff91dd0
commit 256c931db2
6 changed files with 23 additions and 18 deletions

View File

@ -209,6 +209,11 @@ public interface ChannelHandler {
*/ */
void afterRemove(ChannelHandlerContext ctx) throws Exception; void afterRemove(ChannelHandlerContext ctx) throws Exception;
/**
* Gets called if a {@link Throwable} was thrown.
*/
void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception;
/** /**
* Indicates that the same instance of the annotated {@link ChannelHandler} * Indicates that the same instance of the annotated {@link ChannelHandler}
* can be added to one or more {@link ChannelPipeline}s multiple times * can be added to one or more {@link ChannelPipeline}s multiple times

View File

@ -60,4 +60,16 @@ public abstract class ChannelHandlerAdapter implements ChannelHandler {
public void afterRemove(ChannelHandlerContext ctx) throws Exception { public void afterRemove(ChannelHandlerContext ctx) throws Exception {
// NOOP // NOOP
} }
/**
* Calls {@link ChannelHandlerContext#fireExceptionCaught(Throwable)} to forward
* to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
*
* Sub-classes may override this method to change behavior.
*/
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
throws Exception {
ctx.fireExceptionCaught(cause);
}
} }

View File

@ -56,11 +56,6 @@ public interface ChannelStateHandler extends ChannelHandler {
*/ */
void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception; void inboundBufferUpdated(ChannelHandlerContext ctx) throws Exception;
/**
* Gets called if a {@link Throwable} was thrown.
*/
void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception;
/** /**
* Gets called if an user event was triggered. * Gets called if an user event was triggered.
*/ */

View File

@ -79,18 +79,6 @@ public abstract class ChannelStateHandlerAdapter extends ChannelHandlerAdapter i
ctx.fireChannelReadSuspended(); ctx.fireChannelReadSuspended();
} }
/**
* Calls {@link ChannelHandlerContext#fireExceptionCaught(Throwable)} to forward
* to the next {@link ChannelHandler} in the {@link ChannelPipeline}.
*
* Sub-classes may override this method to change behavior.
*/
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)
throws Exception {
ctx.fireExceptionCaught(cause);
}
/** /**
* Calls {@link ChannelHandlerContext#fireUserEventTriggered(Object)} to forward * Calls {@link ChannelHandlerContext#fireUserEventTriggered(Object)} to forward
* to the next {@link ChannelHandler} in the {@link ChannelPipeline}. * to the next {@link ChannelHandler} in the {@link ChannelPipeline}.

View File

@ -812,7 +812,7 @@ final class DefaultChannelHandlerContext extends DefaultAttributeMap implements
throw new NullPointerException("cause"); throw new NullPointerException("cause");
} }
findContextInbound().invokeExceptionCaught(cause); next.invokeExceptionCaught(cause);
return this; return this;
} }

View File

@ -1246,6 +1246,11 @@ final class DefaultChannelPipeline implements ChannelPipeline {
msgSink.release(); msgSink.release();
byteSink.release(); byteSink.release();
} }
@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
ctx.fireExceptionCaught(cause);
}
} }
private static final class ByteHeadHandler extends HeadHandler { private static final class ByteHeadHandler extends HeadHandler {