final DefaultEventController<RequestOutcome> requestOutcomeEventController = new DefaultEventController<>();
final AtomicBoolean transmitted = new AtomicBoolean(false);
final DefaultResponseTransmitter responseTransmitter = new DefaultResponseTransmitter(transmitted, execControl, channel, nettyRequest, request, nettyHeaders, requestOutcomeEventController, launchConfig.isCompressResponses(), shouldCompress, startTime);
final Response response = new DefaultResponse(execControl, responseHeaders, ctx.alloc(), responseTransmitter);
ctx.attr(RESPONSE_TRANSMITTER_ATTRIBUTE_KEY).set(responseTransmitter);
InetSocketAddress socketAddress = (InetSocketAddress) channel.localAddress();
final BindAddress bindAddress = new InetSocketAddressBackedBindAddress(socketAddress);
Action<Action<Object>> subscribeHandler = thing -> {
transmitted.set(true);
channelSubscriptions.put(channel, thing);
channel.closeFuture().addListener(future -> channelSubscriptions.remove(channel));
};
final DirectChannelAccess directChannelAccess = new DefaultDirectChannelAccess(channel, subscribeHandler);
final DefaultContext.RequestConstants requestConstants = new DefaultContext.RequestConstants(
applicationConstants, bindAddress, request, response, directChannelAccess, requestOutcomeEventController.getRegistry()
);
DefaultContext.start(execController.getControl(), requestConstants, registry, handlers, execution -> {
if (!transmitted.get()) {
Handler lastHandler = requestConstants.handler;
StringBuilder description = new StringBuilder();
description
.append("No response sent for ")
.append(request.getMethod().getName())
.append(" request to ")
.append(request.getUri())
.append(" (last handler: ");
if (lastHandler instanceof DescribingHandler) {
((DescribingHandler) lastHandler).describeTo(description);
} else {
DescribingHandlers.describeTo(lastHandler, description);
}
description.append(")");
String message = description.toString();
LOGGER.warn(message);
response.status(500);
if (launchConfig.isDevelopment()) {
response.send(message);
} else {
response.send();
}
}
});
}