Closed
Description
Affects: 6.1.2
In Spring Framework 6.1.1, the following little code snippet worked without any problems:
var uriSpec = WebClient.create()
.get()
.uri("http://localhost:{port}/first", 8080);
Now this same code causes the following IllegalStateException
:
java.lang.IllegalStateException: The port contains a URI variable but has not been expanded yet: {port}
at org.springframework.web.util.HierarchicalUriComponents.getPort(HierarchicalUriComponents.java:193)
at org.springframework.web.util.HierarchicalUriComponents.toUriString(HierarchicalUriComponents.java:488)
at org.springframework.web.util.DefaultUriBuilderFactory$DefaultUriBuilder.toUriString(DefaultUriBuilderFactory.java:416)
at org.springframework.web.reactive.function.client.DefaultWebClient$DefaultRequestBodyUriSpec.uri(DefaultWebClient.java:230)
at org.springframework.web.reactive.function.client.DefaultWebClient$DefaultRequestBodyUriSpec.uri(DefaultWebClient.java:199)
This seems related to the changes made in #30027 and the already mentioned #31882.
Is this a bug, or are we no longer allowed to use URI variables inside the base URL?