study-renjie opened a new issue, #3931:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3931

   
在使用CSERestTemplate进行请求,并且通过JAVASPI使用拦截器ClientHttpRequestInterceptor对请求进行拦截时,存在强转异常,CSE不兼容Spring的原生拦截功能。
   
   报错如下:
   `Failed to execute http request. Exception: {}
   java.lang.ClassCastException: 
org.springframework.http.client.InterceptingClientHttpRequest cannot be cast to 
org.apache.servicecomb.provider.springmvc.reference.CseClientHttpRequest
        at 
org.springframework.web.client.CseHttpMessageConverter.write(CseHttpMessageConverter.java:77)
 ~[provider-springmvc-1.3.0.B012.jar:5.3.27]`
   
   问题代码
   org.springframework:spring-web:5.3.27
   778-782行
   `
   ClientHttpRequest request = createRequest(url, method);
   if (requestCallback != null) {
   requestCallback.doWithRequest(request);
   }
   response = request.execute();
   `
   
   在CSERestTemplate重写了doWithRequest,里面存在强转逻辑
   `
     /**
      * {@inheritDoc}
      */
     @Override
     public void doWithRequest(ClientHttpRequest request) throws IOException {
       orgCallback.doWithRequest(request);
   
       if (!CseHttpEntity.class.isInstance(requestBody)) {
         return;
       }
   
       CseClientHttpRequest req = (CseClientHttpRequest) request;
       CseHttpEntity<?> entity = (CseHttpEntity<?>) requestBody;
       req.setContext(entity.getContext());
     }
   `


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