Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestRestTemplate exchange triggers UnsupportedOperationException when using a UriTemplateRequestEntity #25097

Closed
chrylis opened this issue Feb 3, 2021 · 1 comment
Assignees
Milestone

Comments

@chrylis
Copy link
Contributor

@chrylis chrylis commented Feb 3, 2021

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

@wilkinsona
Copy link
Member

@wilkinsona wilkinsona commented Feb 4, 2021

It looks like we must be missing some tests. I think this change in behaviour is due to this change that was made in Framework 5.3.0.M1.

@wilkinsona wilkinsona self-assigned this Feb 4, 2021
@wilkinsona wilkinsona closed this in 297e307 Feb 4, 2021
@wilkinsona wilkinsona modified the milestones: 2.4.x, 2.4.3 Feb 4, 2021
@wilkinsona wilkinsona changed the title TestRestTemplate exchange triggers UnsupportedOperationException in RequestEntity TestRestTemplate exchange triggers UnsupportedOperationException when using a UriTemplateRequestEntity Feb 4, 2021
This was referenced Mar 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants