Source:
public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { restAccessLoggingHandler.preLog(request); if (!Method.contains(request.method().name())) { NettyRestResponse restResponse = new NettyRestResponse.Builder().status(FORBIDDEN).build(); sendResponse(ctx, request, restResponse); return; } NettyRestRequest restRequest; LookupResult invocationLookup; try { restRequest = new NettyRestRequest(request); invocationLookup = restServer.getRestDispatcher().lookupInvocation(restRequest); } catch (Exception e) { NettyRestResponse restResponse = new NettyRestResponse.Builder().status(BAD_REQUEST).build(); sendResponse(ctx, request, restResponse); return; } if (authenticator == null || isAnon(invocationLookup)) { handleRestRequest(ctx, restRequest, invocationLookup); return; } if (subject != null) { String authz = request.headers().get(HttpHeaderNames.AUTHORIZATION); if (Objects.equals(authz, authorization)) { restRequest.setSubject(subject); handleRestRequest(ctx, restRequest, invocationLookup); return; } else { subject = null; authorization = null; } } authenticator.challenge(restRequest, ctx).whenComplete((authResponse, authThrowable) -> { boolean hasError = authThrowable != null; boolean authorized = authResponse.getStatus() != UNAUTHORIZED.code(); if (!hasError && authorized) { subject = restRequest.getSubject(); authorization = restRequest.getAuthorizationHeader(); restRequest.setSubject(subject); handleRestRequest(ctx, restRequest, invocationLookup); } else { try { if (hasError) { handleError(ctx, request, authThrowable); } else { sendResponse(ctx, request, ((NettyRestResponse) authResponse)); } } finally { request.release(); } } }); }

Target:
public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { restAccessLoggingHandler.preLog(request); if (!Method.contains(request.method().name())) { NettyRestResponse restResponse = new NettyRestResponse.Builder().status(FORBIDDEN).build(); sendResponse(ctx, request, restResponse); return; } NettyRestRequest restRequest; LookupResult invocationLookup; try { restRequest = new NettyRestRequest(request); invocationLookup = restServer.getRestDispatcher().lookupInvocation(restRequest); } catch (Exception e) { NettyRestResponse restResponse = new NettyRestResponse.Builder().status(BAD_REQUEST).build(); sendResponse(ctx, request, restResponse); return; } if (authenticator == null || isAnon(invocationLookup)) { handleRestRequest(ctx, restRequest, invocationLookup); return; } if (subject != null) { String authz = request.headers().get(HttpHeaderNames.AUTHORIZATION); if (Objects.equals(authz, authorization)) { restRequest.setSubject(subject); handleRestRequest(ctx, restRequest, invocationLookup); return; } else { subject = null; authorization = null; } } authenticator.challenge(restRequest, ctx).whenComplete((authResponse, authThrowable) -> { boolean hasError = authThrowable != null; boolean authorized = authResponse.getStatus() != UNAUTHORIZED.code(); if (!hasError && authorized) { authorization = restRequest.getAuthorizationHeader(); subject = restRequest.getSubject(); handleRestRequest(ctx, restRequest, invocationLookup); } else { try { if (hasError) { handleError(ctx, request, authThrowable); } else { sendResponse(ctx, request, ((NettyRestResponse) authResponse)); } } finally { request.release(); } } }); }