2 * Copyright (c) 2013, 2015 EBay Software Foundation and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.ovsdb.lib.jsonrpc;
11 import io.netty.channel.ChannelHandlerAdapter;
12 import io.netty.channel.ChannelHandlerContext;
13 import io.netty.handler.codec.TooLongFrameException;
14 import org.opendaylight.ovsdb.lib.error.InvalidEncodingException;
16 import java.io.IOException;
18 public class ExceptionHandler extends ChannelHandlerAdapter {
21 public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
22 if ((cause instanceof InvalidEncodingException)
23 || (cause instanceof TooLongFrameException)) {
24 ctx.channel().disconnect();
26 /* In cases where a connection is quickly established and the closed
27 Catch the IOException and close the channel
29 if (cause instanceof IOException) {
30 ctx.channel().close();