Commit 2dcf0208 by Nepxion

修正restTemplateStrategyInterceptor可能存在空指针问题

parent 1ef59136
...@@ -49,7 +49,9 @@ public class DiscoveryApplicationA1 { ...@@ -49,7 +49,9 @@ public class DiscoveryApplicationA1 {
@SentinelRestTemplate(blockHandler = "handleException", blockHandlerClass = MySentinelExceptionHandler.class) @SentinelRestTemplate(blockHandler = "handleException", blockHandlerClass = MySentinelExceptionHandler.class)
public RestTemplate restTemplate(@Autowired(required = false) RestTemplateStrategyInterceptor restTemplateStrategyInterceptor) { public RestTemplate restTemplate(@Autowired(required = false) RestTemplateStrategyInterceptor restTemplateStrategyInterceptor) {
RestTemplate restTemplate = new RestTemplate(); RestTemplate restTemplate = new RestTemplate();
restTemplate.setInterceptors(Collections.singletonList(restTemplateStrategyInterceptor)); if (restTemplateStrategyInterceptor != null) {
restTemplate.setInterceptors(Collections.singletonList(restTemplateStrategyInterceptor));
}
return restTemplate; return restTemplate;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment