Source:
protected void messageReceived(final ChannelHandlerContext ctx, final Request request) { if (!ctx.channel().isActive()) { logger.warn("drop request when channel is inActive"); request.release(); return; } final ArgScheme argScheme = ArgScheme.toScheme( request.getTransportHeaders().get(TransportHeaders.ARG_SCHEME_KEY) ); if (argScheme == null) { sendError(ErrorType.BadRequest, "Expected incoming call to have \"as\" header set", request, ctx); return; } final String service = request.getService(); if (service == null || service.isEmpty()) { sendError(ErrorType.BadRequest, "Expected incoming call to have serviceName", request, ctx); return; } String endpoint = request.getArg1().toString(CharsetUtil.UTF_8); if (endpoint == null || endpoint.isEmpty()) { sendError(ErrorType.BadRequest, "Expected incoming call to have endpoint", request, ctx); return; } RequestHandler handler = this.getRequestHandler(service, endpoint); if (handler == null) { handler = topChannel.getDefaultHandler(); } if (handler == null) { sendError(ErrorType.BadRequest, "Invalid handler function", request, ctx); return; } ListenableFuture<Response> responseFuture = listeningExecutorService.submit( new CallableHandler(handler, request)); Futures.addCallback(responseFuture, new FutureCallback<Response>() { @Override public void onSuccess(Response response) { if (!ctx.channel().isActive()) { response.release(); return; } responseQueue.offer(response); sendResponse(ctx); } @Override public void onFailure(Throwable throwable) { logger.error("Failed to handle the request due to exception.", throwable); sendError(ErrorType.UnexpectedError, "Failed to handle the request: " + throwable.getMessage(), request, ctx); return; } }); }

Target:
protected void messageReceived(final ChannelHandlerContext ctx, final Request request) { if (!ctx.channel().isActive()) { logger.warn("drop request when channel is inActive"); request.release(); return; } final ArgScheme argScheme = ArgScheme.toScheme( request.getTransportHeaders().get(TransportHeaders.ARG_SCHEME_KEY) ); if (argScheme == null) { sendError(ErrorType.BadRequest, "Expected incoming call to have \"as\" header set", request, ctx); return; } final String service = request.getService(); if (service == null || service.isEmpty()) { sendError(ErrorType.BadRequest, "Expected incoming call to have serviceName", request, ctx); return; } String endpoint = request.getArg1().toString(CharsetUtil.UTF_8); if (endpoint == null || endpoint.isEmpty()) { sendError(ErrorType.BadRequest, "Expected incoming call to have endpoint", request, ctx); return; } RequestHandler handler = this.getRequestHandler(service, endpoint); if (handler == null) { handler = topChannel.getDefaultUserHandler(); } if (handler == null) { sendError(ErrorType.BadRequest, "Invalid handler function", request, ctx); return; } ListenableFuture<Response> responseFuture = listeningExecutorService.submit( new CallableHandler(handler, request)); Futures.addCallback(responseFuture, new FutureCallback<Response>() { @Override public void onSuccess(Response response) { if (!ctx.channel().isActive()) { response.release(); return; } responseQueue.offer(response); sendResponse(ctx); } @Override public void onFailure(Throwable throwable) { logger.error("Failed to handle the request due to exception.", throwable); sendError(ErrorType.UnexpectedError, "Failed to handle the request: " + throwable.getMessage(), request, ctx); return; } }); }