<commit_before>package org.rackspace.deproxy

import groovy.util.logging.Log4j

import java.text.SimpleDateFormat

import static org.linkedin.groovy.util.concurrent.GroovyConcurrentUtils.waitForCondition

/**
 * A class that acts as a mock HTTP server.
 */

@Log4j
class DeproxyEndpoint {

    String name
    String hostname
    Closure defaultHandler
    ServerConnector serverConnector

    protected Deproxy deproxy;

    public DeproxyEndpoint(Deproxy deproxy, Integer port=null,
                           String name="Endpoint-${System.currentTimeMillis()}",
                           String hostname="localhost", Closure defaultHandler=null,
                           Closure<ServerConnector> connectorFactory=null) {

        this.deproxy = deproxy
        this.name = name
        this.hostname = hostname
        this.defaultHandler = defaultHandler

        if (connectorFactory) {
            this.serverConnector = connectorFactory(this, name);
        } else {
            this.serverConnector = new SocketServerConnector(this, name, port)
        }
    }

    void shutdown() {
        log.debug("Shutting down ${this.name}")
        serverConnector.shutdown()
        log.debug("Finished shutting down ${this.name}")<commit_msg>Grab an open port, if none specified.<commit_after>package org.rackspace.deproxy

import groovy.util.logging.Log4j

import java.text.SimpleDateFormat

import static org.linkedin.groovy.util.concurrent.GroovyConcurrentUtils.waitForCondition

/**
 * A class that acts as a mock HTTP server.
 */

@Log4j
class DeproxyEndpoint {

    String name
    String hostname
    Closure defaultHandler
    ServerConnector serverConnector

    protected Deproxy deproxy;

    public DeproxyEndpoint(Deproxy deproxy, Integer port=null,
                           String name="Endpoint-${System.currentTimeMillis()}",
                           String hostname="localhost", Closure defaultHandler=null,
                           Closure<ServerConnector> connectorFactory=null) {

        this.deproxy = deproxy
        this.name = name
        this.hostname = hostname
        this.defaultHandler = defaultHandler

        if (connectorFactory) {
            this.serverConnector = connectorFactory(this, name);
        } else {
            if (port == null) {
                port = PortFinder.Singleton.getNextOpenPort()
            }
            this.serverConnector = new SocketServerConnector(this, name, port)
        }
    }

    void shutdown() {
        log.debug("Shutting down ${this.name}")
        serverConnector.shutdown()
        log.debug("Finished shutting down ${this.name}")
{'fraction_non_alphanumeric': 0.0833968012185834, 'fraction_numerical': 0.0015232292460015233, 'mean_word_length': 2.4702774108322325, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6438280', 'n_tokens_mistral': 711, 'n_tokens_neox': 698, 'n_words': 158}