| 1231 | } |
| 1232 | |
| 1233 | @Override |
| 1234 | public void exceptionCaught(final ChannelHandlerContext ctx, |
| 1235 | final ExceptionEvent event) { |
| 1236 | final Throwable e = event.getCause(); |
| 1237 | final Channel c = event.getChannel(); |
| 1238 | |
| 1239 | if (e instanceof RejectedExecutionException) { |
| 1240 | LOG.warn("RPC rejected by the executor," |
| 1241 | + " ignore this if we're shutting down", e); |
| 1242 | } else { |
| 1243 | LOG.error("Unexpected exception from downstream on " + c, e); |
| 1244 | } |
| 1245 | if (c.isOpen()) { |
| 1246 | Channels.close(c); // Will trigger channelClosed(), which will cleanup() |
| 1247 | } else { // else: presumably a connection timeout. |
| 1248 | cleanup(c); // => need to cleanup() from here directly. |
| 1249 | } |
| 1250 | } |
| 1251 | |
| 1252 | // ------------------------------- // |
| 1253 | // Low-level encoding and decoding // |