use of com.hotels.styx.server.netty.connectors.HttpPipelineHandler.State.TERMINATED in project styx by ExpediaGroup.
the class HttpPipelineHandler method onResponseObservableError.
private State onResponseObservableError(ChannelHandlerContext ctx, Throwable cause, Object requestId) {
if (!ongoingRequest.id().equals(requestId)) {
return this.state();
}
metrics.proxy().server().requestsCancelled("responseError").increment();
cancelSubscription();
LOGGER.error(warningMessage(format("message='Error proxying request', requestId=%s cause=%s", requestId, cause)));
if (cause instanceof ConsumerDisconnectedException) {
return TERMINATED;
}
LiveHttpResponse response = exceptionToResponse(cause, ongoingRequest, originsHeaderName);
responseWriterFactory.create(ctx).write(response).handle((ignore, exception) -> {
if (exception != null) {
httpErrorStatusListener.proxyErrorOccurred(cause);
httpErrorStatusListener.proxyErrorOccurred(exception);
} else {
httpErrorStatusListener.proxyErrorOccurred(ongoingRequest, remoteAddress(ctx), response.status(), cause);
statsSink.onComplete(ongoingRequest.id(), response.status().code());
tracker.endTrack(ongoingRequest);
}
ctx.close();
return null;
}).handle((ignore, exception) -> {
statsSink.onTerminate(ongoingRequest.id());
tracker.endTrack(ongoingRequest);
if (exception != null) {
LOGGER.error(warningMessage("message='Error during write completion handling'"), exception);
}
return null;
});
return TERMINATED;
}
Aggregations