servicecomb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "bismy" <bi...@qq.com>
Subject 回复: [Discussion][Spring & Spring Boot version upgrade]Behavior of Consumer using RestTemplate had changed
Date Tue, 24 Apr 2018 13:25:41 GMT
I think Spring changed getForObject to return a value regardless the error code(http status)
 is correct because RestTemplate do not have enough information to guess the provider 
which code is successful, e.g. 201, 400, 500 or other. And when developers want to express
400 for error, they should use getForEntity.


For ServiceComb customized RestTemplate implementation this problem not exists. Because we
have API definition to explicitly show which error code is successful, either use
swagger or @ApiResponse .


This is a compatible issue of spring, I think we can upgrade this version following spring
conventions. 




------------------ 原始邮件 ------------------
发件人: "郑扬勇"<yangyong.zheng@qq.com>;
发送时间: 2018年4月24日(星期二) 下午4:01
收件人: "dev"<dev@servicecomb.apache.org>;

主题:  [Discussion][Spring & Spring Boot version upgrade]Behavior of Consumer using
RestTemplate had changed 



Hi everyone:
   The version of Spring & Spring Boot in ServiceComb java chassis are 4.3.5.RELEASE and
1.4.5.RELEASE, seems a little behind, we may upgrade them.
  
  
Spring Boot and Spring Version correlation :
    Spring Boot Version Spring Version
   1.5.8.RELEASE 4.3.12.RELEASE
  1.5.9.RELEASE 4.3.13.RELEASE
  1.5.10.RELEASE 4.3.14.RELEASE
  1.5.11.RELEASE 4.3.15.RELEASE
  1.5.12.RELEASE 4.3.16.RELEASE

   I found if consumer use the RestTemplate make a invocation to our producer and producer
throw an unhande exception, http code with 590 [Cse Internal Server Error] will be return
to consumer side, but the Behavior of RestTemplate getForObject or postForObject in different
version of Spring is also not the same, for example:
  
 ```java
 String result = restTemplate.getForObject("http://127.0.0.1:8080/springmvc/controller/sayhi?name=throwexception",String.class);
 ```
  
 * In 4.3.12.RELEASE still throw UnknownHttpStatusCodeException, same as current (4.3.5.RELEASE)
; 
* In 4.3.13.RELEASE and 4.3.14.RELEASE change to throw org.springframework.web.client.ResourceAccessException
;
* In 4.3.15.RELEASE and 4.3.16.RELEASE won't throw any Exception and direct return {"message":"Cse
Internal Server Error"} .
  
   So if we update the Spring version to 4.3.12.RELEASE above,user may get into trouble when
upgrade 1.0.0-m2, but 4.3.16.RELEASE had fix some bugs and may better in security.
  
 
 
Any other ideas or suggestions are welcome !
 Yangyong Zheng
Best Regards !
 
 
 
consumer code is here : https://github.com/apache/incubator-servicecomb-java-chassis/blob/master/integration-tests/springmvc-tests/src/test/java/org/apache/servicecomb/demo/springmvc/tests/SpringMvcIntegrationTestBase.java
in ensureServerBlowsUp Funcation
 
Example producer will throw RuntimeException,code is here : https://github.com/apache/incubator-servicecomb-java-chassis/blob/master/integration-tests/springmvc-tests/src/test/java/org/apache/servicecomb/demo/springmvc/tests/endpoints/ControllerBase.java
Mime
  • Unnamed multipart/alternative (inline, 8-Bit, 0 bytes)
View raw message