Skip to content

Commit 141e04a

Browse files
violetaggrstoyanchev
authored andcommitted
Fix URI construction in UndertowServerHttpRequest
Ensure there is no "?" at the end of the generated URI when there is no query available.
1 parent 8b7f3a6 commit 141e04a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

spring-web/src/main/java/org/springframework/http/server/reactive/UndertowServerHttpRequest.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.springframework.util.Assert;
3939
import org.springframework.util.LinkedMultiValueMap;
4040
import org.springframework.util.MultiValueMap;
41+
import org.springframework.util.StringUtils;
4142

4243
/**
4344
* Adapt {@link ServerHttpRequest} to the Undertow {@link HttpServerExchange}.
@@ -63,9 +64,10 @@ public UndertowServerHttpRequest(HttpServerExchange exchange, DataBufferFactory
6364
private static URI initUri(HttpServerExchange exchange) {
6465
Assert.notNull(exchange, "HttpServerExchange is required.");
6566
try {
67+
String query = exchange.getQueryString();
6668
return new URI(exchange.getRequestScheme(), null,
6769
exchange.getHostName(), exchange.getHostPort(),
68-
exchange.getRequestURI(), exchange.getQueryString(), null);
70+
exchange.getRequestURI(), StringUtils.hasText(query) ? query : null, null);
6971
}
7072
catch (URISyntaxException ex) {
7173
throw new IllegalStateException("Could not get URI: " + ex.getMessage(), ex);

0 commit comments

Comments
 (0)