<commit_before>package com.timepath.vfs.server.http

import com.timepath.util.concurrent.DaemonThreadFactory
import com.timepath.vfs.provider.ProviderStub
import com.timepath.vfs.SimpleVFile

import java.io.*
import java.net.InetAddress
import java.net.ServerSocket
import java.net.Socket
import java.net.UnknownHostException
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.logging.Level
import java.util.logging.Logger
import com.timepath.vfs.VFile

/**
 * @author TimePath
 */

throws(javaClass<IOException>(), javaClass<UnknownHostException>())
public fun HttpServer(): HttpServer {
    return HttpServer(8000)
}

throws(javaClass<IOException>(), javaClass<UnknownHostException>())
public fun HttpServer(port: Int): HttpServer {
    return HttpServer(port, null)
}

public class HttpServer [throws(javaClass<IOException>(), javaClass<UnknownHostException>())]
(port: Int, addr: InetAddress?) : ProviderStub(), Runnable {
    private val pool = Executors.newFixedThreadPool(10, DaemonThreadFactory())
    private val servsock: ServerSocket

    {
        var addr = addr
        if (addr == null) {
            // On windows, this prevents firewall warnings. It's also good for security in general
            addr = InetAddress.getByName(null) // cannot use java7 InetAddress.getLoopbackAddress().
        }
        servsock = ServerSocket(port, 0, addr)
        LOG.log(Level.INFO, "Listening on {0}:{1}", array<Any>(servsock.getInetAddress().getHostAddress(), servsock.getLocalPort()))
        Runtime.getRuntime().addShutdownHook(Thread(object : Runnable {
            override fun run() {
                LOG.info("HTTP server shutting down...")
            }
        }))
    }

    override fun run() {
        while (true) {
            try {
                pool.submit(HTTPConnection(servsock.accept()))
            } catch (ex: IOException) {
                LOG.log(Level.SEVERE, null, ex)
            }

        }
    }

    private inner class HTTPConnection (private val client: Socket) : Runnable {<commit_msg>Cleanup anonymous objects<commit_after>package com.timepath.vfs.server.http

import com.timepath.util.concurrent.DaemonThreadFactory
import com.timepath.vfs.provider.ProviderStub
import com.timepath.vfs.SimpleVFile

import java.io.*
import java.net.InetAddress
import java.net.ServerSocket
import java.net.Socket
import java.net.UnknownHostException
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
import java.util.logging.Level
import java.util.logging.Logger
import com.timepath.vfs.VFile

/**
 * @author TimePath
 */

throws(javaClass<IOException>(), javaClass<UnknownHostException>())
public fun HttpServer(): HttpServer {
    return HttpServer(8000)
}

throws(javaClass<IOException>(), javaClass<UnknownHostException>())
public fun HttpServer(port: Int): HttpServer {
    return HttpServer(port, null)
}

public class HttpServer [throws(javaClass<IOException>(), javaClass<UnknownHostException>())]
(port: Int, addr: InetAddress?) : ProviderStub(), Runnable {
    private val pool = Executors.newFixedThreadPool(10, DaemonThreadFactory())
    private val servsock: ServerSocket

    {
        var addr = addr
        if (addr == null) {
            // On windows, this prevents firewall warnings. It's also good for security in general
            addr = InetAddress.getByName(null) // cannot use java7 InetAddress.getLoopbackAddress().
        }
        servsock = ServerSocket(port, 0, addr)
        LOG.log(Level.INFO, "Listening on {0}:{1}", array<Any>(servsock.getInetAddress().getHostAddress(), servsock.getLocalPort()))
        Runtime.getRuntime().addShutdownHook(Thread {
            LOG.info("HTTP server shutting down...")
        })
    }

    override fun run() {
        while (true) {
            try {
                pool.submit(HTTPConnection(servsock.accept()))
            } catch (ex: IOException) {
                LOG.log(Level.SEVERE, null, ex)
            }

        }
    }

    private inner class HTTPConnection (private val client: Socket) : Runnable {
{'fraction_non_alphanumeric': 0.11249389946315276, 'fraction_numerical': 0.004880429477794046, 'mean_word_length': 3.3606382978723404, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '5526505', 'n_tokens_mistral': 1174, 'n_tokens_neox': 1142, 'n_words': 268}