Spring Certified Professional 2023 · Free Practice Question Easy
Question 23
Which is true about Spring RestTemplate?
-
A
It is non-blocking
-
B
It is deprecated
-
C
It is reactive
-
D
It won't evolve in the future
Reveal correct answer
Correct answer: D
Explanation
Answer: It won't evolve in the future
1. It is not reactive:
Spring RestTemplate is not a reactive framework.
It is a synchronous HTTP client for making HTTP requests and receiving responses.
If you need to work with reactive programming, you should consider using Spring WebFlux and WebClient.
2. It is blocking:
RestTemplate operates in a blocking manner, which means when you make a request using RestTemplate, it will block the current thread until it receives a response.
This contrasts reactive frameworks like Spring WebFlux, which offer non-blocking alternatives.
3. It won't evolve in the future:
The Spring ecosystem is continuously evolving, and while RestTemplate was widely used in the past for making HTTP requests,
Spring has been encouraging WebClient (a part of Spring WebFlux) to make HTTP requests in modern applications.
RestTemplate may not receive as much attention and improvement in future Spring releases as WebClient.
4. Not Deprecated:
Still, in Spring 6.0.11, RestTemplate was in maintenance mode but not deprecated, and developers were encouraged to use WebClient for new projects.
Check also the next step for RestTemplate: RestClient (https://youtu.be/1VhH3GNAM1k)
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
