yhs0092 opened a new issue, #3434:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3434

   业务直接把真正的 body 放在 ResponseEntity 中, 设置好非 2xx 的状态码返回, 遇到 ClassCastException, 
因为Java-Chassis假设body是`InvocationException`类型的, 直接做了转换, 
关键代码位置在`org.apache.servicecomb.common.rest.filter.inner.ServerRestArgsFilter#beforeSendResponseAsync`:
   ```java
     @Override
     public CompletableFuture<Void> beforeSendResponseAsync(Invocation 
invocation, HttpServletResponseEx responseEx) {
       Response response = (Response) 
responseEx.getAttribute(RestConst.INVOCATION_HANDLER_RESPONSE);
       ProduceProcessor produceProcessor =
           (ProduceProcessor) 
responseEx.getAttribute(RestConst.INVOCATION_HANDLER_PROCESSOR);
       Object body = response.getResult();
       if (response.isFailed()) {
         body = ((InvocationException) body).getErrorData();  // 这里直接强转了 
InvocationException 类型
       }
   ```
   
   这个算是业务比较常见的开发错误, 对于我们来说答疑的成本高, 但Java-Chassis的优化成本应该不高, 能否做一个自动适配的逻辑呢?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to