RequestEntity throws UnsupportedOperationException when using URI template #26500
Labels
for: external-project
Needs a fix in external project
in: web
Issues in web modules (web, webmvc, webflux, websocket)
I'm using Spring Web 5.3.3 with Boot 2.4.2.
When creating a
RequestEntity
by passing in a URI template, the concrete type created is aUriTemplateRequestEntity
, which through itssuper
chain setsthis.url = null
. Later, when theRequestEntity
is passed toRestTemplate#exchange(RequestEntity, Class)
, the template callsRequestEntity#getUrl
. AsUriTemplateRequestEntity
does not overridegetUrl
, this throws becausethis.url == null
.Expected use case:
It appears that what's happening is that the
UriTemplateRequestEntity
's templating methods are bypassed in the simpleexchange
flow. While I'm sure that the expectation was that the style above would be used with URI variables, the fact that it throws an obscure exception is Surprising. Instead, I suggest thatUriTemplateRequestEntity
'sgetUrl
should be overridden, simply returning the string if it is untemplated and possibly throwing an informative exception if it can't be filled out.The text was updated successfully, but these errors were encountered: