Implement UriTemplateRequestEntity::getUrl #27790
Labels
in: web
Issues in web modules (web, webmvc, webflux, websocket)
status: declined
A suggestion or change that we don't feel we should currently apply
type: enhancement
A general enhancement
Affects: Spring Framework 5.3.13
When creating a
RequestEntity
with a template and a parameter list, the resulting URL is not available in the createdRequestEntity
object.For instance, the following code returns a
RequestEntity
with a null URL attribute:r.getUrl()
throws anUnsupportedOperationException
When looking at the code in
RequestEntity.body(String)
, I see that the returned object is anUriTemplateRequestEntity
extendingRequestEntity
, but this object seems to always have anull
URL according to its constructor. Only theuriTemplate
,uriVarsArray
anduriVarsMap
attributes are set. But these attributes are not part ofRequestEntity
.So, the URL information is lost in the RequestEntity and to retrieve it, the resulting object must be cast to an
UriTemplateRequestEntity
, which breaks the encapsulation principle.Shouldn't the
getUrl()
method be overridden inUriTemplateRequestEntity
?A similar issue exists here, but it does not seem to fix the root cause.
I also asked a question about that in Stackoverflow but I guess I only will get workarounds.
The text was updated successfully, but these errors were encountered: