Skip to content

TestRestTemplate exchange triggers UnsupportedOperationException when using a UriTemplateRequestEntity #25097

Closed
@chrylis

Description

@chrylis

In Boot 2.4.2, both overloads of TestRestTemplate#exchange that accept RequestEntity call getUrl on it. When the RequestEntity has been initialized with a URI template instead of a java.net.URI, this triggers an UnsupportedOperationException.

var req = RequestEntity.get("http://localhost/helloworld").build();
var resp = testRestTemplate.exchange(req, String.class);

Internally, the real RestTemplate dispatches based on the concrete type of RequestEntity, but TestRestTemplate fails to check.

see spring-projects/spring-framework#26500

Metadata

Metadata

Assignees

Labels

type: regressionA regression from a previous release

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions