protected void doStart() throws Exception {
InetSocketAddress addr = new InetSocketAddress(port);
this.server = HttpServer.create(addr, 0);
Receiver receiver = new ReceiverImpl(uberClassLoader, createContext());
final RemoteControlHttpHandler handler = new RemoteControlHttpHandler(receiver);
server.createContext("/", new HttpHandler()
{
@Override
public void handle(final HttpExchange exchange) throws IOException {
int id = requests.incrementAndGet();
log.debug("Handling remote request: [{}] {}", id, exchange);
DC.put(RemoteScript.class, id);
try {
handler.handle(exchange);
}
catch (Throwable failure) {
// HACK: Ignore this package-private exception as it seems to happen normally
if ("sun.net.httpserver.StreamClosedException".equals(failure.getClass().getCanonicalName())) {
log.trace("Ignoring", failure);