Source:
<code>private void handleProxyResponse(Request serverRequest, final Response serverResponse, ExecutionContext executionContext, ProxyResponse proxyResponse, long serviceInvocationStart, Handler<Response> handler) { if (proxyResponse == null || proxyResponse instanceof DirectProxyConnection.DirectResponse) { serverResponse.status((proxyResponse == null) ? HttpStatusCode.SERVICE_UNAVAILABLE_503 : proxyResponse.status()); serverResponse.end(); handler.handle(serverResponse); } else { serverResponse.status(proxyResponse.status()); proxyResponse.headers().forEach((headerName, headerValues) -> serverResponse.headers().put(headerName, headerValues)); PolicyChain responsePolicyChain = apiPolicyResolver.resolve(StreamType.ON_RESPONSE, serverRequest, serverResponse, executionContext); responsePolicyChain.setResultHandler(responsePolicyResult -> { if (responsePolicyResult.isFailure()) { sendPolicyFailure(responsePolicyResult, serverResponse); handler.handle(serverResponse); } else { responsePolicyChain.bodyHandler(chunk -> { serverResponse.write(chunk); serverRequest.metrics().setResponseContentLength( serverRequest.metrics().getResponseContentLength() + chunk.length() ); }); responsePolicyChain.endHandler(responseEndResult -> { serverRequest.metrics().setApiResponseTimeMs(System.currentTimeMillis() - serviceInvocationStart); serverResponse.end(); handler.handle(serverResponse); }); proxyResponse.bodyHandler(buffer -> { if(serverResponse.writeQueueFull()) { <START> System.out.println("pausing"); <END> proxyResponse.pause(); serverResponse.drainHandler(aVoid -> { System.out.println("resuming"); proxyResponse.resume(); }); } responsePolicyChain.write(buffer); }); proxyResponse.endHandler(aVoid -> responsePolicyChain.end()); } }); responsePolicyChain.setStreamErrorHandler(result -> { sendPolicyFailure(result, serverResponse); handler.handle(serverResponse); }); responsePolicyChain.doNext(serverRequest, serverResponse); proxyResponse.resume(); } }</code><technical_language>remove</technical_language>

Target:
private void handleProxyResponse(Request serverRequest, final Response serverResponse, ExecutionContext executionContext, ProxyResponse proxyResponse, long serviceInvocationStart, Handler<Response> handler) { if (proxyResponse == null || proxyResponse instanceof DirectProxyConnection.DirectResponse) { serverResponse.status((proxyResponse == null) ? HttpStatusCode.SERVICE_UNAVAILABLE_503 : proxyResponse.status()); serverResponse.end(); handler.handle(serverResponse); } else { serverResponse.status(proxyResponse.status()); proxyResponse.headers().forEach((headerName, headerValues) -> serverResponse.headers().put(headerName, headerValues)); PolicyChain responsePolicyChain = apiPolicyResolver.resolve(StreamType.ON_RESPONSE, serverRequest, serverResponse, executionContext); responsePolicyChain.setResultHandler(responsePolicyResult -> { if (responsePolicyResult.isFailure()) { sendPolicyFailure(responsePolicyResult, serverResponse); handler.handle(serverResponse); } else { responsePolicyChain.bodyHandler(chunk -> { serverResponse.write(chunk); serverRequest.metrics().setResponseContentLength( serverRequest.metrics().getResponseContentLength() + chunk.length() ); }); responsePolicyChain.endHandler(responseEndResult -> { serverRequest.metrics().setApiResponseTimeMs(System.currentTimeMillis() - serviceInvocationStart); serverResponse.end(); handler.handle(serverResponse); }); proxyResponse.bodyHandler(buffer -> { if(serverResponse.writeQueueFull()) { proxyResponse.pause(); serverResponse.drainHandler(aVoid -> proxyResponse.resume()); } responsePolicyChain.write(buffer); }); proxyResponse.endHandler(aVoid -> responsePolicyChain.end()); } }); responsePolicyChain.setStreamErrorHandler(result -> { sendPolicyFailure(result, serverResponse); handler.handle(serverResponse); }); responsePolicyChain.doNext(serverRequest, serverResponse); proxyResponse.resume(); } }