<commit_before>package ie.omk.smpp;

import ie.omk.smpp.event.ReceiverExitEvent;
import ie.omk.smpp.event.SMPPEvent;
import ie.omk.smpp.message.SMPPPacket;
import ie.omk.smpp.util.APIConfig;
import ie.omk.smpp.util.PacketFactory;
import ie.omk.smpp.util.SMPPIO;

import java.io.IOException;
import java.net.SocketTimeoutException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Receiver thread for the connection.
 * @version $Id:$
 */
class ReceiverThread extends Thread {
    private static final Logger LOG = LoggerFactory.getLogger(ReceiverThread.class);
    
    private Connection connection;
    private byte[] buffer = new byte[128];
    
    ReceiverThread(Connection connection) {
        this.connection = connection;
    }
    
    @Override
    public void run() {
        LOG.debug("Receiver thread starting.");
        SMPPEvent exitEvent = null;
        try {
            exitEvent = processPackets();
        } catch (Exception x) {
            exitEvent = new ReceiverExitEvent(connection, x);
        }
        connection.getEventDispatcher().notifyObservers(connection, exitEvent);
        LOG.debug("Destroying event dispatcher.");
        connection.getEventDispatcher().destroy();
        LOG.debug("Receiver thread exiting.");
    }

    private ReceiverExitEvent processPackets() throws Exception {
        ReceiverExitEvent exitEvent = null;
        int ioExceptions = 0;
        final int ioExceptionLimit = APIConfig.getInstance().getInt(
                APIConfig.TOO_MANY_IO_EXCEPTIONS, 5);
        
        SMPPPacket packet = null;
        while (connection.getState() != ConnectionState.UNBOUND) {
            try {
                packet = readNextPacket();
                if (packet == null) {
                    continue;
                }
                connection.processReceivedPacket(packet);
                connection.getEventDispatcher().notifyObservers(connection, packet);
                ioExceptions = 0;
            } catch (SocketTimeoutException x) {
                ConnectionState state = connection.getState();
                if (state == ConnectionState.BINDING) {<commit_msg>Change the timeout exception from SocketTimeoutException to ReadTimeoutException.<commit_after>package ie.omk.smpp;

import ie.omk.smpp.event.ReceiverExitEvent;
import ie.omk.smpp.event.SMPPEvent;
import ie.omk.smpp.message.SMPPPacket;
import ie.omk.smpp.net.ReadTimeoutException;
import ie.omk.smpp.util.APIConfig;
import ie.omk.smpp.util.PacketFactory;
import ie.omk.smpp.util.SMPPIO;

import java.io.IOException;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Receiver thread for the connection.
 * @version $Id:$
 */
class ReceiverThread extends Thread {
    private static final Logger LOG = LoggerFactory.getLogger(ReceiverThread.class);
    
    private Connection connection;
    private byte[] buffer = new byte[128];
    
    ReceiverThread(Connection connection) {
        this.connection = connection;
        setDaemon(true);
    }
    
    @Override
    public void run() {
        LOG.debug("Receiver thread starting.");
        SMPPEvent exitEvent = null;
        try {
            exitEvent = processPackets();
        } catch (Exception x) {
            exitEvent = new ReceiverExitEvent(connection, x);
        }
        connection.getEventDispatcher().notifyObservers(connection, exitEvent);
        LOG.debug("Destroying event dispatcher.");
        connection.getEventDispatcher().destroy();
        LOG.debug("Receiver thread exiting.");
    }

    private ReceiverExitEvent processPackets() throws Exception {
        ReceiverExitEvent exitEvent = null;
        int ioExceptions = 0;
        final int ioExceptionLimit = APIConfig.getInstance().getInt(
                APIConfig.TOO_MANY_IO_EXCEPTIONS, 5);
        
        SMPPPacket packet = null;
        while (connection.getState() != ConnectionState.UNBOUND) {
            try {
                packet = readNextPacket();
                if (packet == null) {
                    continue;
                }
                connection.processReceivedPacket(packet);
                connection.getEventDispatcher().notifyObservers(connection, packet);
                ioExceptions = 0;
            } catch (ReadTimeoutException x) {
                ConnectionState state = connection.getState();
                if (state == ConnectionState.BINDING) {
{'fraction_non_alphanumeric': 0.09586551567469333, 'fraction_numerical': 0.003634711494775102, 'mean_word_length': 2.4944444444444445, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3617658', 'n_tokens_mistral': 1213, 'n_tokens_neox': 1170, 'n_words': 256}