Ganesh Pathak
Ganesh Pathak

Reputation: 123

Why there is no patchForEntity method just like postForEntity in RestTemplate?

I would like to know why there is no patchForEntity method provided in RestTemplate class same like postForEntity and getForEntity. Only patchForObject method is there which only returns the object but not the ResponseEntity.

To get the ResponseEntity for a PATCH request, we have to use the exchange method of RestTemplate, which is OK, but I am really curious why the Spring guys haven't provided a handy patchForEntity method.

Any clue?

Upvotes: 6

Views: 889

Answers (1)

asherbret
asherbret

Reputation: 6038

A similar issue has been opened in Spring's GitHub. To quote from the answer that was given there:

... While it would be technically possible to introduce a patchForEntity() method, analogous to the existing getForEntity() and postForEntity() methods, there are no plans to introduce new functionality in the RestTemplate API ...

So, to answer your question, there seems to be no technical reason why this functionality wasn't provided, just that the priority to do so wasn't high enough, since, as you mentioned in your question, you can achieve the effect you want using the exchange method. Anyway (and this was news to me), "there are no plans to introduce new functionality in the RestTemplate API" because it's going to be deprecated in favor of WebClient, so odds are RestTemplate will never have the patchForEntity() method.

Upvotes: 2

Related Questions