You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by "study-renjie (via GitHub)" <gi...@apache.org> on 2023/08/31 06:58:54 UTC

[GitHub] [servicecomb-java-chassis] study-renjie opened a new issue, #3931: CseRestTemplate不能使用ClientHttpRequestInterceptor,存在强转异常

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: commits-unsubscribe@servicecomb.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #3931: CseRestTemplate不能使用ClientHttpRequestInterceptor,存在强转异常

Posted by "liubao68 (via GitHub)" <gi...@apache.org>.
liubao68 commented on issue #3931:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3931#issuecomment-1709413982

   see https://github.com/apache/servicecomb-java-chassis/issues/3931


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #3931: CseRestTemplate不能使用ClientHttpRequestInterceptor,存在强转异常

Posted by "liubao68 (via GitHub)" <gi...@apache.org>.
liubao68 commented on issue #3931:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3931#issuecomment-1709413479

   java chassis提供了RestTemplate调用微服务,但是实现并不是基于SpringMVC的,不能使用ClientHttpRequestInterceptor。 对于请求的拦截和处理,需要使用 Handler 或者 HttpClientFilter。 


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] mainsunshine01 commented on issue #3931: CseRestTemplate不能使用ClientHttpRequestInterceptor,存在强转异常

Posted by "mainsunshine01 (via GitHub)" <gi...@apache.org>.
mainsunshine01 commented on issue #3931:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3931#issuecomment-1706389200

   898


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] mainsunshine01 commented on issue #3931: CseRestTemplate不能使用ClientHttpRequestInterceptor,存在强转异常

Posted by "mainsunshine01 (via GitHub)" <gi...@apache.org>.
mainsunshine01 commented on issue #3931:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3931#issuecomment-1706389389

   > 898
   
   90


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] mainsunshine01 commented on issue #3931: CseRestTemplate不能使用ClientHttpRequestInterceptor,存在强转异常

Posted by "mainsunshine01 (via GitHub)" <gi...@apache.org>.
mainsunshine01 commented on issue #3931:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3931#issuecomment-1706389727

   > > 898
   > 
   > 90
   
   898uygshafsqgvahbjnkmagshabjn是为更好的给我回车都不是·


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [servicecomb-java-chassis] liubao68 closed issue #3931: CseRestTemplate不能使用ClientHttpRequestInterceptor,存在强转异常

Posted by "liubao68 (via GitHub)" <gi...@apache.org>.
liubao68 closed issue #3931: CseRestTemplate不能使用ClientHttpRequestInterceptor,存在强转异常
URL: https://github.com/apache/servicecomb-java-chassis/issues/3931


-- 
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: commits-unsubscribe@servicecomb.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org