@Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        if (msg instanceof HttpResponse) {
            HttpResponse resp = (HttpResponse) msg;
            // Make sure it's a failure first
            if (resp.status().code() >= 300) {
                dumpToSdkHttpResponse(resp);
            }
        }

        if (msg instanceof HttpContent) {
            cumulateContent(ctx, (HttpContent) msg);
        }
        if (msg instanceof LastHttpContent) {
            try {
                responseHandler.onFailure(unmarshallError());
            } catch (Exception e) {
                responseHandler.onFailure(new SdkClientException("Unable to unmarshall error response.", e));
            } finally {
                notifiedOnFailure = true;
                ReferenceCountUtil.release(cumulation);
                ctx.close();
            }
        }
    }
Flag to make sure we only notify {@link PutMediaAckResponseHandler#onFailure(Throwable)} once.
aws-java-sdk-kinesisvideo/src/main/java/com/amazonaws/services/kinesisvideo/internal/netty/handler/ErrorUnmarshallingHandler.java