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