https://github.com/spring-projects/spring-framework/blob/8e81360eba8cca33522872cdf48eb5f0b84644cb/spring-web/src/main/java/org/springframework/web/client/RestTemplate.java#L734

🐱‍💻When I read the RestTemplate.doExecute() source code, I found that it was based on a very old version of the JDK, and I knew that Spring5 was built on JDK 8.Such as this

   protected <T> T doExecute(URI url, @Nullable HttpMethod method, @Nullable RequestCallback requestCallback,
            @Nullable ResponseExtractor<T> responseExtractor) throws RestClientException {

        Assert.notNull(url, "URI is required");
        Assert.notNull(method, "HttpMethod is required");

        try (ClientHttpResponse  response = new ClientHttpResponse()){
            ClientHttpRequest request = createRequest(url, method);
            if (requestCallback != null) {
                requestCallback.doWithRequest(request);
            }
            response = request.execute();
            handleResponse(url, method, response);
            return (responseExtractor != null ? responseExtractor.extractData(response) : null);
        }
        catch (IOException ex) {
            String resource = url.toString();
            String query = url.getRawQuery();
            resource = (query != null ? resource.substring(0, resource.indexOf('?')) : resource);
            throw new ResourceAccessException("I/O error on " + method.name() +
                    " request for \"" + resource + "\": " + ex.getMessage(), ex);
        }
    }

⛳Doing so makes the code more maintainable. The maintainer doesn't need to focus on anything else that doesn't matter. what do you think ?

Comment From: m1ngyuan

@XiaoZiShan ClientHttpResponse is as interface,you can't call construnctor

Comment From: XiaoZiShan

@XiaoZiShan ClientHttpResponse is as interface,you can't call construnctor

我把 spring 源码项目打开看看

Comment From: XiaoZiShan

@XiaoZiShan ClientHttpResponse is as interface,you can't call construnctor 😋Hit the face, not on the editor of the PR and issue do not count, implies not on the scale do not know how much weight several