mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Deprecate RestTemplate and related types
As announced in "the state of HTTP clients in Spring" blog post (https://spring.io/blog/2025/09/30/the-state-of-http-clients-in-spring), the deprecation timeline for `RestTemplate` was announced last November and docs were updated accordingly. This commit `@Deprecate` `RestTemplate` and related types for removal to send a stronger signal to our community. The actual removal is scheduled for Spring Framework 8.0 (not yet scheduled). Closes gh-36574
This commit is contained in:
+1
@@ -35,6 +35,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class InterceptingHttpAccessorTests {
|
||||
|
||||
@Test
|
||||
|
||||
+1
@@ -57,6 +57,7 @@ import static org.springframework.http.HttpStatus.UNPROCESSABLE_ENTITY;
|
||||
* Tests for {@link DefaultResponseErrorHandler} handling of specific
|
||||
* HTTP status codes.
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class DefaultResponseErrorHandlerHttpStatusTests {
|
||||
|
||||
private final DefaultResponseErrorHandler handler = new DefaultResponseErrorHandler();
|
||||
|
||||
+1
@@ -44,6 +44,7 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Juergen Hoeller
|
||||
* @author Denys Ivano
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class DefaultResponseErrorHandlerTests {
|
||||
|
||||
private final DefaultResponseErrorHandler handler = new DefaultResponseErrorHandler();
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ import static org.mockito.Mockito.mock;
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
@SuppressWarnings("removal")
|
||||
class ExtractingResponseErrorHandlerTests {
|
||||
|
||||
private ExtractingResponseErrorHandler errorHandler;
|
||||
|
||||
+1
@@ -52,6 +52,7 @@ import static org.mockito.Mockito.mock;
|
||||
* @author Brian Clozel
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class HttpMessageConverterExtractorTests {
|
||||
|
||||
private final HttpMessageConverter<String> converter = mock();
|
||||
|
||||
@@ -49,7 +49,7 @@ import static org.assertj.core.api.Assertions.fail;
|
||||
*/
|
||||
class RestClientBuilderTests {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "removal"})
|
||||
@Test
|
||||
void createFromRestTemplate() {
|
||||
JettyClientHttpRequestFactory requestFactory = new JettyClientHttpRequestFactory();
|
||||
@@ -90,6 +90,7 @@ class RestClientBuilderTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("removal")
|
||||
void defaultUriBuilderFactory() {
|
||||
RestTemplate restTemplate = new RestTemplate();
|
||||
|
||||
|
||||
+1
@@ -82,6 +82,7 @@ import static org.springframework.http.MediaType.MULTIPART_MIXED;
|
||||
* @author Brian Clozel
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class RestTemplateIntegrationTests extends AbstractMockWebServerTests {
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
|
||||
+1
@@ -55,6 +55,7 @@ import static org.springframework.http.HttpMethod.GET;
|
||||
* Tests for the client HTTP observations with {@link RestTemplate}.
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@SuppressWarnings("removal")
|
||||
class RestTemplateObservationTests {
|
||||
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ import static org.springframework.http.MediaType.parseMediaType;
|
||||
* @author Brian Clozel
|
||||
* @author Sam Brannen
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SuppressWarnings({"unchecked", "removal"})
|
||||
class RestTemplateTests {
|
||||
|
||||
private final ClientHttpRequestFactory requestFactory = mock();
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ import static org.assertj.core.api.Assertions.assertThatThrownBy;
|
||||
* @author Rossen Stoyanchev
|
||||
* @author Brian Clozel
|
||||
*/
|
||||
@SuppressWarnings("JUnitMalformedDeclaration")
|
||||
@SuppressWarnings({"JUnitMalformedDeclaration", "removal"})
|
||||
class RestClientAdapterTests {
|
||||
|
||||
private final MockWebServer anotherServer = new MockWebServer();
|
||||
|
||||
+1
@@ -34,6 +34,7 @@ import kotlin.reflect.jvm.kotlinFunction
|
||||
*
|
||||
* @author Sebastien Deleuze
|
||||
*/
|
||||
@Suppress("REMOVAL", "DEPRECATION")
|
||||
class RestOperationsExtensionsTests {
|
||||
|
||||
val template = mockk<RestOperations>()
|
||||
|
||||
+2
-2
@@ -28,7 +28,6 @@ import org.springframework.http.ResponseEntity
|
||||
import org.springframework.util.LinkedMultiValueMap
|
||||
import org.springframework.util.MultiValueMap
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import org.springframework.web.client.RestTemplate
|
||||
import org.springframework.web.multipart.MultipartFile
|
||||
import org.springframework.web.service.annotation.GetExchange
|
||||
import org.springframework.web.service.annotation.PostExchange
|
||||
@@ -46,6 +45,7 @@ import java.util.*
|
||||
*
|
||||
* @author Olga Maciaszek-Sharma
|
||||
*/
|
||||
@Suppress("REMOVAL", "DEPRECATION")
|
||||
class KotlinRestTemplateHttpServiceProxyTests {
|
||||
|
||||
private lateinit var server: MockWebServer
|
||||
@@ -65,7 +65,7 @@ class KotlinRestTemplateHttpServiceProxyTests {
|
||||
}
|
||||
|
||||
private fun initTestService(): TestService {
|
||||
val restTemplate = RestTemplate()
|
||||
val restTemplate = org.springframework.web.client.RestTemplate()
|
||||
restTemplate.uriTemplateHandler = DefaultUriBuilderFactory(server.url("/").toString())
|
||||
return HttpServiceProxyFactory.builder()
|
||||
.exchangeAdapter(RestTemplateAdapter.create(restTemplate))
|
||||
|
||||
Reference in New Issue
Block a user