<commit_before>package server;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.nio.ByteBuffer;

public class PlayerParticipant extends Thread {
	private InputStream input;
	private Socket socket;
	private Statebox stateBox;

	public PlayerParticipant(Socket socket, Statebox stateBox) {
		try {
			this.socket = socket;
			this.stateBox = stateBox;
			input = socket.getInputStream();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void run() {
		while(!socket.isClosed()){
			try {
				byte[] intBytes = new byte[4];
				for(int i = 0; i < 4; i++){
					intBytes[i] = (byte) input.read();
				}
				int msgLen = ByteBuffer.wrap(intBytes).getInt();
				
				byte[] msg = new byte[msgLen+4];
				for(int i = 0; i < 4; i++){
					msg[i] = intBytes[i];
				}
				
				for(int i = 4; i < msg.length; i++){
					msg[i] = (byte) input.read();
				}
				stateBox.writeMessage(msg);
	
			} catch(ArrayIndexOutOfBoundsException aioobe){
				System.out.println("Message not complete.");
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		stateBox.removeClientSocket(socket);
	}
}<commit_msg>Closes the socket when arrayoutofbounds when reading incomplete message.<commit_after>package server;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.nio.ByteBuffer;

public class PlayerParticipant extends Thread {
	private InputStream input;
	private Socket socket;
	private Statebox stateBox;

	public PlayerParticipant(Socket socket, Statebox stateBox) {
		try {
			this.socket = socket;
			this.stateBox = stateBox;
			input = socket.getInputStream();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	@Override
	public void run() {
		while(!socket.isClosed()){
			try {
				byte[] intBytes = new byte[4];
				for(int i = 0; i < 4; i++){
					intBytes[i] = (byte) input.read();
				}
				int msgLen = ByteBuffer.wrap(intBytes).getInt();
				
				byte[] msg = new byte[msgLen+4];
				for(int i = 0; i < 4; i++){
					msg[i] = intBytes[i];
				}
				
				for(int i = 4; i < msg.length; i++){
					msg[i] = (byte) input.read();
				}
				stateBox.writeMessage(msg);
	
			} catch(ArrayIndexOutOfBoundsException aioobe){
				System.out.println("Message not complete.");
				try {
					socket.close();
					System.out.println("Socket closed.");
				} catch (IOException e) {
					e.printStackTrace();
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		stateBox.removeClientSocket(socket);
	}
}
{'fraction_non_alphanumeric': 0.1398188263095707, 'fraction_numerical': 0.005513981882630957, 'mean_word_length': 3.219269102990033, 'pattern_counts': {'":': 0, '<': 9, '<?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': '5821432', 'n_tokens_mistral': 1024, 'n_tokens_neox': 824, 'n_words': 204}