WillemJiang commented on a change in pull request #653: [SCB-483] Springmvc rest vertx file download URL: https://github.com/apache/incubator-servicecomb-java-chassis/pull/653#discussion_r182291768
########## File path: common/common-rest/src/main/java/org/apache/servicecomb/common/rest/AbstractRestInvocation.java ########## @@ -220,10 +216,38 @@ protected void sendResponse(Response response) throws Exception { responseEx.setAttribute(RestConst.INVOCATION_HANDLER_RESPONSE, response); responseEx.setAttribute(RestConst.INVOCATION_HANDLER_PROCESSOR, produceProcessor); - for (HttpServerFilter filter : httpServerFilters) { - filter.beforeSendResponse(invocation, responseEx); + executeHttpServerFilters(response); + } + + protected void executeHttpServerFilters(Response response) { + HttpServerFilterBeforeSendResponseExecutor exec = + new HttpServerFilterBeforeSendResponseExecutor(httpServerFilters, invocation, responseEx); + CompletableFuture<Void> future = exec.run(); + future.whenComplete((v, e) -> { + onExecuteHttpServerFiltersFinish(response, e); + }); + } + + protected void onExecuteHttpServerFiltersFinish(Response response, Throwable e) { + if (e != null) { + LOGGER.error("Failed to execute HttpServerFilters, operation:{}.", + invocation.getMicroserviceQualifiedName(), + e); } - responseEx.flushBuffer(); + try { + responseEx.flushBuffer(); + } catch (IOException flushException) { + LOGGER.error("Failed to flush rest response, operation:{}.", + invocation.getMicroserviceQualifiedName(), + flushException); + } + + requestEx.getAsyncContext().complete(); + // if failed to locate path, then will not create invocation + // TODO: statistics this case Review comment: We may also need to count the error and exceptions. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services