<commit_before>/*
 * 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.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.handler.timeout.ReadTimeoutException;
import java.io.IOException;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.OvsdbConnection;
import org.opendaylight.ovsdb.lib.error.InvalidEncodingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ExceptionHandler extends ChannelDuplexHandler {

    private static final Logger LOG = LoggerFactory.getLogger(ExceptionHandler.class);

    private final OvsdbConnection ovsdbConnectionService;

    public ExceptionHandler(OvsdbConnection ovsdbConnectionService) {
        this.ovsdbConnectionService = ovsdbConnectionService;
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        if (ctx.channel().isActive()) {
            LOG.error("Exception occurred while processing connection pipeline", cause);
            if ((cause instanceof InvalidEncodingException)
                    || (cause instanceof TooLongFrameException || (cause instanceof DecoderException))) {
                LOG.info("Disconnecting channel to ovsdb {}", ctx.channel());
                ctx.channel().disconnect();
                return;
            }

        /* In cases where a connection is quickly established and the closed
        Catch the IOException and close the channel. Similarly if the peer is
        powered off, Catch the read time out exception and close the channel
         */
            if ((cause instanceof IOException) || (cause instanceof ReadTimeoutException)) {
                LOG.info("Closing channel to ovsdb {}", ctx.channel());
                ctx.channel().close();
                return;
            }

            LOG.error("Exception was not handled by the exception handler, re-throwing it for next handler");<commit_msg>Change log level from ERROR to warn.<commit_after>/*
 * 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.ChannelDuplexHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.TooLongFrameException;
import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import io.netty.handler.timeout.ReadTimeoutException;
import java.io.IOException;
import org.opendaylight.ovsdb.lib.OvsdbClient;
import org.opendaylight.ovsdb.lib.OvsdbConnection;
import org.opendaylight.ovsdb.lib.error.InvalidEncodingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class ExceptionHandler extends ChannelDuplexHandler {

    private static final Logger LOG = LoggerFactory.getLogger(ExceptionHandler.class);

    private final OvsdbConnection ovsdbConnectionService;

    public ExceptionHandler(OvsdbConnection ovsdbConnectionService) {
        this.ovsdbConnectionService = ovsdbConnectionService;
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
        if (ctx.channel().isActive()) {
            LOG.warn("Exception occurred while processing connection pipeline", cause);
            if ((cause instanceof InvalidEncodingException)
                    || (cause instanceof TooLongFrameException || (cause instanceof DecoderException))) {
                LOG.info("Disconnecting channel to ovsdb {}", ctx.channel());
                ctx.channel().disconnect();
                return;
            }

        /* In cases where a connection is quickly established and the closed
        Catch the IOException and close the channel. Similarly if the peer is
        powered off, Catch the read time out exception and close the channel
         */
            if ((cause instanceof IOException) || (cause instanceof ReadTimeoutException)) {
                LOG.info("Closing channel to ovsdb {}", ctx.channel());
                ctx.channel().close();
                return;
            }

            LOG.error("Exception was not handled by the exception handler, re-throwing it for next handler");
{'fraction_non_alphanumeric': 0.08276278695126862, 'fraction_numerical': 0.005638340716874748, 'mean_word_length': 3.380070546737213, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2565505', 'n_tokens_mistral': 1305, 'n_tokens_neox': 1250, 'n_words': 371}