[ 
https://issues.apache.org/jira/browse/SCB-483?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16441795#comment-16441795
 ] 

ASF GitHub Bot commented on SCB-483:
------------------------------------

wujimin 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_r182294530
 
 

 ##########
 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:
   traced by https://issues.apache.org/jira/browse/SCB-500

----------------------------------------------------------------
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


> springmvc over transport rest vertx support file download
> ---------------------------------------------------------
>
>                 Key: SCB-483
>                 URL: https://issues.apache.org/jira/browse/SCB-483
>             Project: Apache ServiceComb
>          Issue Type: Sub-task
>          Components: Java-Chassis
>            Reporter: wujimin
>            Assignee: wujimin
>            Priority: Major
>




--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to