You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by "lcyzhyx-520 (via GitHub)" <gi...@apache.org> on 2023/03/09 03:24:02 UTC

[GitHub] [servicecomb-java-chassis] lcyzhyx-520 opened a new issue, #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

lcyzhyx-520 opened a new issue, #3697:
URL: https://github.com/apache/servicecomb-java-chassis/issues/3697

   java.lang.OutOfMemoryError: Java heap space
   	at java.util.Arrays.copyOf(Arrays.java:3236)
   	at java.io.ByteArrayOutputStream.grow(ByteArrayOutputStream.java:118)
   	at java.io.ByteArrayOutputStream.ensureCapacity(ByteArrayOutputStream.java:93)
   	at java.io.ByteArrayOutputStream.write(ByteArrayOutputStream.java:153)
   	at org.springframework.util.StreamUtils.copy(StreamUtils.java:167)
   	at org.springframework.util.FileCopyUtils.copy(FileCopyUtils.java:112)
   	at org.springframework.util.FileCopyUtils.copyToByteArray(FileCopyUtils.java:152)
   	at org.springframework.web.client.HttpMessageConverterExtractor.getResponseBody(HttpMessageConverterExtractor.java:148)
   	at org.springframework.web.client.HttpMessageConverterExtractor.extractData(HttpMessageConverterExtractor.java:126)
   	at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:996)
   	at org.springframework.web.client.RestTemplate$ResponseEntityResponseExtractor.extractData(RestTemplate.java:979)
   	at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:739)
   	at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:693)
   	at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:620)
   	at org.apache.servicecomb.provider.springmvc.reference.RestTemplateWrapper.exchange(RestTemplateWrapper.java:184)
   
   ![image](https://user-images.githubusercontent.com/63617742/223908518-320981ea-ce9e-41a2-ac3a-62188acfc514.png)
   
   
   
   


-- 
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] lcyzhyx-520 closed issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

Posted by "lcyzhyx-520 (via GitHub)" <gi...@apache.org>.
lcyzhyx-520 closed issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM
URL: https://github.com/apache/servicecomb-java-chassis/issues/3697


-- 
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] lbc97 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   > > OOM不是内存溢出吗 跟泛型有什么关系呢
   > 
   > messageConverter解析带有泛型的返回结果时,有bug,会导致OOM
   
   具体是什么bug呢 有分析吗


-- 
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] lcyzhyx-520 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   > > 这个应该是非常基础的功能来的。 有没有写一个简单的DEMO验证下? 还是由于其他因素导致的?比如消息太大之类的。
   > 
   > 其实这个我简单复现了一下没发现问题
   > 
   > cosumer 端demo: public interface ProviderService { List list(); }
   > 
   > ======== RestSchema(schemaId = "ConsumerController") @RequestMapping(path = "/") public class ConsumerController { @RpcReference(schemaId = "ProviderController", microserviceName = "provider") private ProviderService providerService;
   > 
   > @GetMapping("/list") public List list(){ return providerService.list(); } }
   > 
   > ======== provider端demo: @RestSchema(schemaId = "ProviderController") @RequestMapping(path = "/") public class ProviderController { @GetMapping("/list") public List list() { List list = new ArrayList<>(); list.add("1"); list.add("2"); return list; } }
   
   
   
   问题解决了。  
   
           final ParameterizedTypeReference<?> typeReference = ParameterizedTypeReference.forType(
               method.getGenericReturnType());
           responseEntity = template.exchange(requestUrl, httpMethod, entity, typeReference, params.getPathVariables());
   
   我们之前的调用方式有问题, 代码如上所示。  这里处理ParameterizedTypeReference有问题。 
   修改为 responseEntity = template.exchange(requestUrl, httpMethod, entity, method.getReturnType(),
                   params.getPathVariables());
   就正常了


-- 
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] lbc97 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   > 这个应该是非常基础的功能来的。 有没有写一个简单的DEMO验证下? 还是由于其他因素导致的?比如消息太大之类的。
   
   其实这个我简单复现了一下没发现问题
   
   cosumer 端demo:
   public interface ProviderService {
     List<String> list();
   }
   ========
   RestSchema(schemaId = "ConsumerController")
   @RequestMapping(path = "/")
   public class ConsumerController {
     @RpcReference(schemaId = "ProviderController", microserviceName = "provider")
     private ProviderService providerService;
   
     @GetMapping("/list")
     public List<String> list(){
       return providerService.list();
     }
    }
   
   
   provider端demo:
   @RestSchema(schemaId = "ProviderController")
   @RequestMapping(path = "/")
   public class ProviderController {
     @GetMapping("/list")
     public List<String> list() {
       List<String> list =  new ArrayList<>();
       list.add("1");
       list.add("2");
       return list;
     }
   }


-- 
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] lcyzhyx-520 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   > > > > 这个应该是非常基础的功能来的。 有没有写一个简单的DEMO验证下? 还是由于其他因素导致的?比如消息太大之类的。
   > > > 
   > > > 
   > > > 其实这个我简单复现了一下没发现问题
   > > > cosumer 端demo: public interface ProviderService { List list(); }
   > > > ======== RestSchema(schemaId = "ConsumerController") @RequestMapping(path = "/") public class ConsumerController { @RpcReference(schemaId = "ProviderController", microserviceName = "provider") private ProviderService providerService;
   > > > @GetMapping("/list") public List list(){ return providerService.list(); } }
   > > > ======== provider端demo: @RestSchema(schemaId = "ProviderController") @RequestMapping(path = "/") public class ProviderController { @GetMapping("/list") public List list() { List list = new ArrayList<>(); list.add("1"); list.add("2"); return list; } }
   > > 
   > > 
   > > 问题解决了。
   > > ```
   > >     final ParameterizedTypeReference<?> typeReference = ParameterizedTypeReference.forType(
   > >         method.getGenericReturnType());
   > >     responseEntity = template.exchange(requestUrl, httpMethod, entity, typeReference, params.getPathVariables());
   > > ```
   > > 
   > > 
   > >     
   > >       
   > >     
   > > 
   > >       
   > >     
   > > 
   > >     
   > >   
   > > 我们之前的调用方式有问题, 代码如上所示。 这里处理ParameterizedTypeReference有问题。 修改为 responseEntity = template.exchange(requestUrl, httpMethod, entity, method.getReturnType(), params.getPathVariables()); 就正常了
   > 
   > 这是你们自己写的rpc调用逻辑是吧 跟你们那个自定义注解一起配套使用的是吗
   
   是的。 自己实现的rpc调用逻辑。 配合 自定义的@RPCClient注解使用。


-- 
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] yanghao605 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   demo能更详细一点吗


-- 
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] lcyzhyx-520 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   > 
   
   
   例如: 
   
   返回结果为 Result<String>时,会报错OOM 。 不支持泛型。 
   
   ![image](https://user-images.githubusercontent.com/63617742/224007272-a7ec5047-ea5f-41f0-a06d-ca8736708081.png)
   
   ![image](https://user-images.githubusercontent.com/63617742/224007371-d60630d1-9448-42c6-a232-157090738398.png)
   
   ![image](https://user-images.githubusercontent.com/63617742/224007414-05d0f7c5-6d83-40a4-80dc-4570d45775dc.png)
   
   


-- 
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] lcyzhyx-520 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   > OOM不是内存溢出吗 跟泛型有什么关系呢
   
   messageConverter解析带有泛型的返回结果时,有bug,会导致OOM


-- 
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] lcyzhyx-520 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   > > > OOM不是内存溢出吗 跟泛型有什么关系呢
   > > 
   > > 
   > > messageConverter解析带有泛型的返回结果时,有bug,会导致OOM
   > 
   > 具体是什么bug呢 有分析吗
   
   有的, CseHttpMessageConverter 不支持泛型。 但是CseRestTemplate不支持拓展converter


-- 
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] lbc97 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   现在问题解决了 看看是否可以关闭这个issue


-- 
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] lcyzhyx-520 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   > 你使用的框架版本是啥 你demo里面的@RpcClient注解是我们框架里面的吗。
   
   这个是我们自己实现的注解。 内部还是通过调用CseRestTemplate来访问的


-- 
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 #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   这个应该是非常基础的功能来的。 有没有写一个简单的DEMO验证下? 还是由于其他因素导致的?比如消息太大之类的。 


-- 
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] lcyzhyx-520 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   > 还有那个Result 都是你们自定义的还是其他第三方依赖都详细说明一下
   
   我们自定义的返回体。 
   
   @Getter
   @Setter
   @ToString
   @NoArgsConstructor
   public class Result<T> {
       private static final long serialVersionUID = 1L;
   
       private int code;
   
       private boolean success;
   
       private T data;
   
       private String msg;
   
       private String errorCode;
   }
   


-- 
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] lcyzhyx-520 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   > > > > 这个应该是非常基础的功能来的。 有没有写一个简单的DEMO验证下? 还是由于其他因素导致的?比如消息太大之类的。
   > > > 
   > > > 
   > > > 其实这个我简单复现了一下没发现问题
   > > > cosumer 端demo: public interface ProviderService { List list(); }
   > > > ======== RestSchema(schemaId = "ConsumerController") @RequestMapping(path = "/") public class ConsumerController { @RpcReference(schemaId = "ProviderController", microserviceName = "provider") private ProviderService providerService;
   > > > @GetMapping("/list") public List list(){ return providerService.list(); } }
   > > > ======== provider端demo: @RestSchema(schemaId = "ProviderController") @RequestMapping(path = "/") public class ProviderController { @GetMapping("/list") public List list() { List list = new ArrayList<>(); list.add("1"); list.add("2"); return list; } }
   > > 
   > > 
   > > 问题解决了。
   > > ```
   > >     final ParameterizedTypeReference<?> typeReference = ParameterizedTypeReference.forType(
   > >         method.getGenericReturnType());
   > >     responseEntity = template.exchange(requestUrl, httpMethod, entity, typeReference, params.getPathVariables());
   > > ```
   > > 
   > > 
   > >     
   > >       
   > >     
   > > 
   > >       
   > >     
   > > 
   > >     
   > >   
   > > 我们之前的调用方式有问题, 代码如上所示。 这里处理ParameterizedTypeReference有问题。 修改为 responseEntity = template.exchange(requestUrl, httpMethod, entity, method.getReturnType(), params.getPathVariables()); 就正常了
   > 
   > 这是你们自己写的rpc调用逻辑是吧 跟你们那个自定义注解一起配套使用的是吗
   
   是的。 自己实现的rpc调用逻辑。 配合 自定义的@RPCClient注解使用。


-- 
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] lbc97 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   > > > 这个应该是非常基础的功能来的。 有没有写一个简单的DEMO验证下? 还是由于其他因素导致的?比如消息太大之类的。
   > > 
   > > 
   > > 其实这个我简单复现了一下没发现问题
   > > cosumer 端demo: public interface ProviderService { List list(); }
   > > ======== RestSchema(schemaId = "ConsumerController") @RequestMapping(path = "/") public class ConsumerController { @RpcReference(schemaId = "ProviderController", microserviceName = "provider") private ProviderService providerService;
   > > @GetMapping("/list") public List list(){ return providerService.list(); } }
   > > ======== provider端demo: @RestSchema(schemaId = "ProviderController") @RequestMapping(path = "/") public class ProviderController { @GetMapping("/list") public List list() { List list = new ArrayList<>(); list.add("1"); list.add("2"); return list; } }
   > 
   > 问题解决了。
   > 
   > ```
   >     final ParameterizedTypeReference<?> typeReference = ParameterizedTypeReference.forType(
   >         method.getGenericReturnType());
   >     responseEntity = template.exchange(requestUrl, httpMethod, entity, typeReference, params.getPathVariables());
   > ```
   > 
   > 我们之前的调用方式有问题, 代码如上所示。 这里处理ParameterizedTypeReference有问题。 修改为 responseEntity = template.exchange(requestUrl, httpMethod, entity, method.getReturnType(), params.getPathVariables()); 就正常了
   
   这是你们自己写的rpc调用逻辑是吧 跟你们那个自定义注解一起配套使用的是吗


-- 
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] lbc97 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   OOM不是内存溢出吗 跟泛型有什么关系呢


-- 
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] lbc97 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   你使用的框架版本是啥 你demo里面的@RpcClient注解是我们框架里面的吗。


-- 
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] lbc97 commented on issue #3697: CSE调用方式,返回结果类型为ParameterizedTypeReference时, 会导致OOM

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

   还有那个Result<String> 都是你们自定义的还是其他第三方依赖都详细说明一下


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