Skip to content

Commit 0542fe5

Browse files
committed
Update ClientHttpRequestInterceptor javadoc
Clarify the interceptor is responsible for closing the response if it throws an exception after receiving it. Closes gh-29751
1 parent c7b832c commit 0542fe5

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

spring-web/src/main/java/org/springframework/http/client/ClientHttpRequestInterceptor.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2018 the original author or authors.
2+
* Copyright 2002-2023 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,14 +21,10 @@
2121
import org.springframework.http.HttpRequest;
2222

2323
/**
24-
* Intercepts client-side HTTP requests. Implementations of this interface can be
25-
* {@linkplain org.springframework.web.client.RestTemplate#setInterceptors registered}
26-
* with the {@link org.springframework.web.client.RestTemplate RestTemplate},
27-
* as to modify the outgoing {@link ClientHttpRequest} and/or the incoming
28-
* {@link ClientHttpResponse}.
29-
*
30-
* <p>The main entry point for interceptors is
31-
* {@link #intercept(HttpRequest, byte[], ClientHttpRequestExecution)}.
24+
* Contract to intercept client-side HTTP requests. Implementations can be
25+
* registered with {@link org.springframework.web.client.RestClient} or
26+
* {@link org.springframework.web.client.RestTemplate} to modify the outgoing
27+
* request and/or the incoming response.
3228
*
3329
* @author Arjen Poutsma
3430
* @since 3.1
@@ -55,6 +51,8 @@ public interface ClientHttpRequestInterceptor {
5551
* </ul>
5652
* <li>Optionally wrap the response to filter HTTP attributes.</li>
5753
* </ol>
54+
* <p>Note: if the interceptor throws an exception after receiving a response,
55+
* it must close the response via {@link ClientHttpResponse#close()}.
5856
* @param request the request, containing method, URI, and headers
5957
* @param body the body of the request
6058
* @param execution the request execution

0 commit comments

Comments
 (0)