<commit_before>package jaci.openrio.toast.core.network;

import jaci.openrio.delegate.BoundDelegate;
import jaci.openrio.delegate.Security;
import jaci.openrio.toast.core.Toast;
import jaci.openrio.toast.core.ToastConfiguration;
import jaci.openrio.toast.core.command.CommandBus;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * A one-way delegate for the Command Line. This Delegate will only receive messages and will interpret them as commands.
 * No data will be sent to the client from this delegate. To read the output log, it's recommended to use the {@link jaci.openrio.toast.core.network.LoggerDelegate}
 *
 * DelegateID: "TOAST_command"
 *
 * @author Jaci
 */
public class CommandDelegate implements BoundDelegate.ConnectionCallback {

    static BoundDelegate server;

    public static void init() {
        server = SocketManager.register("TOAST_command");
        String pass = ToastConfiguration.Property.COMMANDS_DELEGATE_PASSWORD.asString();
        String algorithm = ToastConfiguration.Property.COMMANDS_DELEGATE_ALGORITHM.asString();
        if (pass != null && !pass.equals("")) {
            if (algorithm != null && Security.HashType.match(algorithm) != null)
                server.setPassword(pass, Security.HashType.match(algorithm));
            else
                server.setPassword(pass);
        }
        CommandDelegate instance = new CommandDelegate();
        server.callback(instance);
    }

    @Override
    public void onClientConnect(Socket clientSocket, BoundDelegate delegate) {
        new Thread() {
            public void run() {
                this.setName("CommandDelegate");
                try {
                    BufferedReader reader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                    while (true)
                        CommandBus.parseMessage(reader.readLine());
                } catch (Throwable e) {
                    Toast.log().error("Could not read Command Client: ");
                }
            }
        }.start();
    }

}
<commit_msg>Ignore the error so the socket will shutdown<commit_after>package jaci.openrio.toast.core.network;

import jaci.openrio.delegate.BoundDelegate;
import jaci.openrio.delegate.Security;
import jaci.openrio.toast.core.Toast;
import jaci.openrio.toast.core.ToastConfiguration;
import jaci.openrio.toast.core.command.CommandBus;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.Socket;

/**
 * A one-way delegate for the Command Line. This Delegate will only receive messages and will interpret them as commands.
 * No data will be sent to the client from this delegate. To read the output log, it's recommended to use the {@link jaci.openrio.toast.core.network.LoggerDelegate}
 *
 * DelegateID: "TOAST_command"
 *
 * @author Jaci
 */
public class CommandDelegate implements BoundDelegate.ConnectionCallback {

    static BoundDelegate server;

    public static void init() {
        server = SocketManager.register("TOAST_command");
        String pass = ToastConfiguration.Property.COMMANDS_DELEGATE_PASSWORD.asString();
        String algorithm = ToastConfiguration.Property.COMMANDS_DELEGATE_ALGORITHM.asString();
        if (pass != null && !pass.equals("")) {
            if (algorithm != null && Security.HashType.match(algorithm) != null)
                server.setPassword(pass, Security.HashType.match(algorithm));
            else
                server.setPassword(pass);
        }
        CommandDelegate instance = new CommandDelegate();
        server.callback(instance);
    }

    @Override
    public void onClientConnect(Socket clientSocket, BoundDelegate delegate) {
        new Thread() {
            public void run() {
                this.setName("CommandDelegate");
                try {
                    BufferedReader reader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
                    while (true) {
                        String line = reader.readLine();
                        if (line != null)
                            CommandBus.parseMessage(line);
                        else {
                            try {
                                clientSocket.close();
                            } catch (Exception e) {}
                            break;
                        }
                    }
                } catch (Throwable e) {
                    Toast.log().error("Could not read Command Client: ");
                }
            }
        }.start();
    }

}

{'fraction_non_alphanumeric': 0.09375, 'fraction_numerical': 0.0, 'mean_word_length': 2.289156626506024, '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': '3633534', 'n_tokens_mistral': 1209, 'n_tokens_neox': 1162, 'n_words': 290}