public static void handleRejection()

in zuul-core/src/main/java/com/netflix/netty/common/throttle/RejectionUtils.java [166:211]


    public static void handleRejection(
            ChannelHandlerContext ctx,
            Object msg,
            RejectionType rejectionType,
            StatusCategory nfStatus,
            String reason,
            @Nullable Integer injectedLatencyMillis,
            HttpResponseStatus rejectedCode,
            String rejectedBody,
            Map<String, String> rejectionHeaders) {

        boolean shouldDropMessage = false;
        if (rejectionType == RejectionType.REJECT || rejectionType == RejectionType.CLOSE) {
            shouldDropMessage = true;
        }

        boolean shouldRejectNow = false;
        if (rejectionType == RejectionType.REJECT && msg instanceof LastHttpContent) {
            shouldRejectNow = true;
        } else if (rejectionType == RejectionType.CLOSE && msg instanceof HttpRequest) {
            shouldRejectNow = true;
        } else if (rejectionType == RejectionType.ALLOW_THEN_CLOSE && msg instanceof HttpRequest) {
            shouldRejectNow = true;
        }

        if (shouldRejectNow) {
            // Send a rejection response.
            HttpRequest request = msg instanceof HttpRequest ? (HttpRequest) msg : null;
            reject(
                    ctx,
                    rejectionType,
                    nfStatus,
                    reason,
                    request,
                    injectedLatencyMillis,
                    rejectedCode,
                    rejectedBody,
                    rejectionHeaders);
        }

        if (shouldDropMessage) {
            ReferenceCountUtil.safeRelease(msg);
        } else {
            ctx.fireChannelRead(msg);
        }
    }