<commit_before>package no.ueland.uHoneyPot;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.util.Set;

/**
 * Created by Ueland on 4/13/17.
 */
public class PortHandler implements Runnable {

    private static Selector selector = null;
    private final int port;

    public PortHandler(int port) {
        this.port = port;
        try {
            selector = Selector.open();
        } catch (IOException e) {
            Util.die(e);
        }
    }

    @Override
    public void run() {
        try {
            ServerSocketChannel server = ServerSocketChannel.open();
            server.configureBlocking(false);
            server.socket().bind(new InetSocketAddress(port));
            server.register(selector, SelectionKey.OP_ACCEPT);

            while (selector.isOpen()) {
                selector.select();
                Set readyKeys = selector.selectedKeys();
                for (Object readyKey : readyKeys) {
                    SelectionKey key = (SelectionKey) readyKey;
                    if (key.isAcceptable()) {
                        new Thread(new SocketHandler(server.accept().socket())).start();
                    }
                }
            }

        }catch(Exception ex) {
            Util.die(ex);
        }
    }
}
<commit_msg>PortHandler.java: Fixed bugs around socket creation<commit_after>package no.ueland.uHoneyPot;

import java.net.ServerSocket;
import java.net.Socket;

/**
 * Created by Ueland on 4/13/17.
 */
class PortHandler implements Runnable {

    private final int port;

    public PortHandler(int port) {
        this.port = port;
    }

    @Override
    public void run() {
        try {
            ServerSocket listener = new ServerSocket(this.port);
            try {
                while (true) {
                    Socket socket = listener.accept();
                    new Thread(new SocketHandler(socket)).start();
                }
            } finally {
                listener.close();
            }
        }catch(Exception ex) {
            Util.die(ex);
        }
    }
}

{'fraction_non_alphanumeric': 0.10249433106575964, 'fraction_numerical': 0.0045351473922902496, 'mean_word_length': 1.7575, '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': '4817670', 'n_tokens_mistral': 605, 'n_tokens_neox': 569, 'n_words': 132}