Search in sources :

Example 1 with InvalidRipostePipelineException

use of com.nike.riposte.server.error.exception.InvalidRipostePipelineException in project riposte by Nike-Inc.

the class RequestHasBeenHandledVerificationHandler method doChannelRead.

@Override
public PipelineContinuationBehavior doChannelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
    if (msg == null) {
        throw new InvalidRipostePipelineException("msg cannot be null at this stage of the pipeline. An endpoint handler should have fired a valid " + "OutboundMessage. invalid_riposte_pipeline=true");
    }
    if (!(msg instanceof OutboundMessage)) {
        throw new InvalidRipostePipelineException("Expected msg to be a OutboundMessage, but instead found: " + msg.getClass().getName() + ". invalid_riposte_pipeline=true");
    }
    HttpProcessingState state = ChannelAttributes.getHttpProcessingStateForChannel(ctx).get();
    if (state == null) {
        throw new InvalidRipostePipelineException("Found null HttpProcessingState in the channel, which is not allowed at this point. " + "invalid_riposte_pipeline=true");
    }
    ResponseInfo<?> responseInfo = state.getResponseInfo();
    if (responseInfo == null) {
        throw new InvalidRipostePipelineException("Found null ResponseInfo in the channel state, which is not allowed at this point. " + "An endpoint handler should have set a ResponseInfo on the state. invalid_riposte_pipeline=true");
    }
    if (responseInfo.isChunkedResponse() && !(msg instanceof ChunkedOutboundMessage)) {
        throw new InvalidRipostePipelineException("ResponseInfo.isChunkedResponse() indicates a chunked response, but the message was not a " + "ChunkedOutboundMessage. msg_type=" + msg.getClass().getName() + ", invalid_riposte_pipeline=true");
    }
    if (!responseInfo.isChunkedResponse() && !(msg instanceof LastOutboundMessageSendFullResponseInfo)) {
        throw new InvalidRipostePipelineException("ResponseInfo.isChunkedResponse() indicates a full response, but the message was not a " + "LastOutboundMessageSendFullResponseInfo. msg_type=" + msg.getClass().getName() + ", invalid_riposte_pipeline=true");
    }
    return CONTINUE;
}
Also used : HttpProcessingState(com.nike.riposte.server.http.HttpProcessingState) ChunkedOutboundMessage(com.nike.riposte.server.channelpipeline.message.ChunkedOutboundMessage) OutboundMessage(com.nike.riposte.server.channelpipeline.message.OutboundMessage) InvalidRipostePipelineException(com.nike.riposte.server.error.exception.InvalidRipostePipelineException) ChunkedOutboundMessage(com.nike.riposte.server.channelpipeline.message.ChunkedOutboundMessage) LastOutboundMessageSendFullResponseInfo(com.nike.riposte.server.channelpipeline.message.LastOutboundMessageSendFullResponseInfo)

Aggregations

ChunkedOutboundMessage (com.nike.riposte.server.channelpipeline.message.ChunkedOutboundMessage)1 LastOutboundMessageSendFullResponseInfo (com.nike.riposte.server.channelpipeline.message.LastOutboundMessageSendFullResponseInfo)1 OutboundMessage (com.nike.riposte.server.channelpipeline.message.OutboundMessage)1 InvalidRipostePipelineException (com.nike.riposte.server.error.exception.InvalidRipostePipelineException)1 HttpProcessingState (com.nike.riposte.server.http.HttpProcessingState)1