Remove ChannelHandlerLifeCycleException and just use ChannelPipelineException as replacement

This commit is contained in:
Norman Maurer 2012-12-21 17:10:36 +01:00
parent ef555d268c
commit a819d26f5c
2 changed files with 11 additions and 66 deletions

View File

@ -1,55 +0,0 @@
/*
* Copyright 2012 The Netty Project
*
* The Netty Project licenses this file to you under the Apache License,
* version 2.0 (the "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*/
package io.netty.channel;
/**
* A {@link RuntimeException} which is thrown when a
* {@link LifeCycleAwareChannelHandler} throws an {@link Exception}
* in its handler methods.
*
* @apiviz.exclude
*/
public class ChannelHandlerLifeCycleException extends RuntimeException {
private static final long serialVersionUID = 8764799996088850672L;
/**
* Creates a new exception.
*/
public ChannelHandlerLifeCycleException() {
}
/**
* Creates a new exception.
*/
public ChannelHandlerLifeCycleException(String message, Throwable cause) {
super(message, cause);
}
/**
* Creates a new exception.
*/
public ChannelHandlerLifeCycleException(String message) {
super(message);
}
/**
* Creates a new exception.
*/
public ChannelHandlerLifeCycleException(Throwable cause) {
super(cause);
}
}

View File

@ -581,8 +581,8 @@ public class DefaultChannelPipeline implements ChannelPipeline {
} }
name2ctx.put(newName, newCtx); name2ctx.put(newName, newCtx);
ChannelHandlerLifeCycleException removeException = null; ChannelPipelineException removeException = null;
ChannelHandlerLifeCycleException addException = null; ChannelPipelineException addException = null;
boolean removed = false; boolean removed = false;
try { try {
callAfterRemove(ctx); callAfterRemove(ctx);
@ -591,7 +591,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
ctx.readable(true); ctx.readable(true);
removed = true; removed = true;
} catch (ChannelHandlerLifeCycleException e) { } catch (ChannelPipelineException e) {
removeException = e; removeException = e;
} }
@ -599,14 +599,14 @@ public class DefaultChannelPipeline implements ChannelPipeline {
try { try {
callAfterAdd(newCtx); callAfterAdd(newCtx);
added = true; added = true;
} catch (ChannelHandlerLifeCycleException e) { } catch (ChannelPipelineException e) {
addException = e; addException = e;
} }
if (!removed && !added) { if (!removed && !added) {
logger.warn(removeException.getMessage(), removeException); logger.warn(removeException.getMessage(), removeException);
logger.warn(addException.getMessage(), addException); logger.warn(addException.getMessage(), addException);
throw new ChannelHandlerLifeCycleException( throw new ChannelPipelineException(
"Both " + ctx.handler().getClass().getName() + "Both " + ctx.handler().getClass().getName() +
".afterRemove() and " + newCtx.handler().getClass().getName() + ".afterRemove() and " + newCtx.handler().getClass().getName() +
".afterAdd() failed; see logs."); ".afterAdd() failed; see logs.");
@ -622,7 +622,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
if (handler instanceof ChannelStateHandlerAdapter) { if (handler instanceof ChannelStateHandlerAdapter) {
ChannelStateHandlerAdapter h = (ChannelStateHandlerAdapter) handler; ChannelStateHandlerAdapter h = (ChannelStateHandlerAdapter) handler;
if (!h.isSharable() && h.added) { if (!h.isSharable() && h.added) {
throw new ChannelHandlerLifeCycleException( throw new ChannelPipelineException(
h.getClass().getName() + h.getClass().getName() +
" is not a @Sharable handler, so can't be added or removed multiple times."); " is not a @Sharable handler, so can't be added or removed multiple times.");
} }
@ -631,7 +631,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
try { try {
handler.beforeAdd(ctx); handler.beforeAdd(ctx);
} catch (Throwable t) { } catch (Throwable t) {
throw new ChannelHandlerLifeCycleException( throw new ChannelPipelineException(
handler.getClass().getName() + handler.getClass().getName() +
".beforeAdd() has thrown an exception; not adding.", t); ".beforeAdd() has thrown an exception; not adding.", t);
} }
@ -652,11 +652,11 @@ public class DefaultChannelPipeline implements ChannelPipeline {
} }
if (removed) { if (removed) {
throw new ChannelHandlerLifeCycleException( throw new ChannelPipelineException(
ctx.handler().getClass().getName() + ctx.handler().getClass().getName() +
".afterAdd() has thrown an exception; removed.", t); ".afterAdd() has thrown an exception; removed.", t);
} else { } else {
throw new ChannelHandlerLifeCycleException( throw new ChannelPipelineException(
ctx.handler().getClass().getName() + ctx.handler().getClass().getName() +
".afterAdd() has thrown an exception; also failed to remove.", t); ".afterAdd() has thrown an exception; also failed to remove.", t);
} }
@ -667,7 +667,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
try { try {
ctx.handler().beforeRemove(ctx); ctx.handler().beforeRemove(ctx);
} catch (Throwable t) { } catch (Throwable t) {
throw new ChannelHandlerLifeCycleException( throw new ChannelPipelineException(
ctx.handler().getClass().getName() + ctx.handler().getClass().getName() +
".beforeRemove() has thrown an exception; not removing.", t); ".beforeRemove() has thrown an exception; not removing.", t);
} }
@ -677,7 +677,7 @@ public class DefaultChannelPipeline implements ChannelPipeline {
try { try {
ctx.handler().afterRemove(ctx); ctx.handler().afterRemove(ctx);
} catch (Throwable t) { } catch (Throwable t) {
throw new ChannelHandlerLifeCycleException( throw new ChannelPipelineException(
ctx.handler().getClass().getName() + ctx.handler().getClass().getName() +
".afterRemove() has thrown an exception.", t); ".afterRemove() has thrown an exception.", t);
} }