Skip to content

Commit c9df303

Browse files
committed
Merge branch 'main' into pr/3761
2 parents 4fdf22e + fb2a32b commit c9df303

File tree

19 files changed

+81
-28
lines changed

19 files changed

+81
-28
lines changed

.github/workflows/maven.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Set up JDK
2020
uses: actions/setup-java@v4
2121
with:
22-
distribution: 'temurin'
22+
distribution: 'liberica'
2323
java-version: '17'
2424
cache: 'maven'
2525
- name: Build with Maven

docs/modules/ROOT/pages/spring-cloud-gateway-server-webmvc/starter.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
To include Spring Cloud Gateway Server Web MVC in your project, use the starter with a group ID of `org.springframework.cloud` and an artifact ID of `spring-cloud-starter-gateway-server-webmvc`.
66
See the https://projects.spring.io/spring-cloud/[Spring Cloud Project page] for details on setting up your build system with the current Spring Cloud Release Train.
77

8-
If you include the starter, but you do not want the gateway to be enabled, set `spring.cloud.gateway.mvc.enabled=false`.
8+
If you include the starter, but you do not want the gateway to be enabled, set `spring.cloud.gateway.server.webmvc.enabled=false`.
99

1010
IMPORTANT: Spring Cloud Gateway Server MVC is built on https://spring.io/projects/spring-boot#learn[Spring Boot] and https://docs.spring.io/spring-framework/reference/web/webmvc-functional.html[Spring WebMvc.fn].
1111
As a consequence, many of the asynchronous or reactive libraries may not apply when you use Spring Cloud Gateway Server MVC.

spring-cloud-gateway-server-mvc/pom.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,4 +146,19 @@
146146
<scope>test</scope>
147147
</dependency>
148148
</dependencies>
149+
150+
<build>
151+
<plugins>
152+
<plugin>
153+
<groupId>org.apache.maven.plugins</groupId>
154+
<artifactId>maven-surefire-plugin</artifactId>
155+
<configuration>
156+
<systemPropertyVariables>
157+
<!-- TODO: github actions fails with restricted header host -->
158+
<jdk.httpclient.allowRestrictedHeaders>host</jdk.httpclient.allowRestrictedHeaders>
159+
</systemPropertyVariables>
160+
</configuration>
161+
</plugin>
162+
</plugins>
163+
</build>
149164
</project>

spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/GatewayMvcClassPathWarningAutoConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
2323
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass;
2424
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
25+
import org.springframework.cloud.gateway.server.mvc.config.GatewayMvcProperties;
2526
import org.springframework.context.annotation.Configuration;
2627

2728
@Configuration(proxyBeanMethods = false)
2829
@AutoConfigureBefore(GatewayServerMvcAutoConfiguration.class)
29-
@ConditionalOnProperty(name = "spring.cloud.gateway.mvc.enabled", matchIfMissing = true)
30+
@ConditionalOnProperty(name = GatewayMvcProperties.PREFIX + ".enabled", matchIfMissing = true)
3031
public class GatewayMvcClassPathWarningAutoConfiguration {
3132

3233
private static final Log log = LogFactory.getLog(GatewayMvcClassPathWarningAutoConfiguration.class);

spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/GatewayServerMvcAutoConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
@AutoConfiguration(after = { HttpClientAutoConfiguration.class, RestTemplateAutoConfiguration.class,
7979
RestClientAutoConfiguration.class, FilterAutoConfiguration.class, HandlerFunctionAutoConfiguration.class,
8080
PredicateAutoConfiguration.class })
81-
@ConditionalOnProperty(name = "spring.cloud.gateway.mvc.enabled", matchIfMissing = true)
81+
@ConditionalOnProperty(name = GatewayMvcProperties.PREFIX + ".enabled", matchIfMissing = true)
8282
@Import(GatewayMvcPropertiesBeanDefinitionRegistrar.class)
8383
@ImportRuntimeHints(GatewayMvcAotRuntimeHintsRegistrar.class)
8484
public class GatewayServerMvcAutoConfiguration {

spring-cloud-gateway-server-mvc/src/main/java/org/springframework/cloud/gateway/server/mvc/filter/BeforeFilterFunctions.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
import org.springframework.web.servlet.function.ServerRequest;
4646
import org.springframework.web.util.UriComponentsBuilder;
4747
import org.springframework.web.util.UriTemplate;
48-
import org.springframework.web.util.UriUtils;
4948

5049
import static org.springframework.cloud.gateway.server.mvc.common.MvcUtils.CIRCUITBREAKER_EXECUTION_EXCEPTION_ATTR;
5150
import static org.springframework.util.CollectionUtils.unmodifiableMultiValueMap;
@@ -216,7 +215,7 @@ public static Function<ServerRequest, ServerRequest> removeRequestParameter(Stri
216215
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>(request.params());
217216
queryParams.remove(name);
218217

219-
MultiValueMap<String, String> encodedQueryParams = UriUtils.encodeQueryParams(queryParams);
218+
MultiValueMap<String, String> encodedQueryParams = MvcUtils.encodeQueryParams(queryParams);
220219

221220
// remove from uri
222221
URI newUri = UriComponentsBuilder.fromUri(request.uri())
@@ -351,7 +350,7 @@ public static Function<ServerRequest, ServerRequest> rewriteRequestParameter(Str
351350
queryParams.add(name, replacement);
352351
}
353352

354-
MultiValueMap<String, String> encodedQueryParams = UriUtils.encodeQueryParams(queryParams);
353+
MultiValueMap<String, String> encodedQueryParams = MvcUtils.encodeQueryParams(queryParams);
355354
URI rewrittenUri = UriComponentsBuilder.fromUri(request.uri())
356355
.replaceQueryParams(unmodifiableMultiValueMap(encodedQueryParams))
357356
.build(true)

spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/VanillaRouterFunctionTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
import static org.springframework.cloud.gateway.server.mvc.predicate.GatewayRequestPredicates.host;
4444

4545
@SuppressWarnings("unchecked")
46-
@SpringBootTest(properties = { "spring.cloud.gateway.mvc.http-client.type=jdk" },
46+
@SpringBootTest(properties = { "spring.http.client.factory=jdk" },
4747
webEnvironment = WebEnvironment.RANDOM_PORT)
4848
@ContextConfiguration(initializers = HttpbinTestcontainers.class)
4949
public class VanillaRouterFunctionTests {

spring-cloud-gateway-server-mvc/src/test/java/org/springframework/cloud/gateway/server/mvc/filter/BeforeFilterFunctionsTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,17 @@ void rewriteEncodedRequestParameter() {
119119
MockHttpServletRequest servletRequest = MockMvcRequestBuilders.get("http://localhost/path")
120120
.param("foo[]", "bar")
121121
.param("baz", "qux")
122+
.param("quux", "corge+")
122123
.buildRequest(null);
123124

124125
ServerRequest request = ServerRequest.create(servletRequest, Collections.emptyList());
125126

126127
ServerRequest result = BeforeFilterFunctions.rewriteRequestParameter("foo[]", "replacement[]").apply(request);
127128

128129
assertThat(result.param("foo[]")).isPresent().hasValue("replacement[]");
129-
assertThat(result.uri().toString()).hasToString("http://localhost/path?baz=qux&foo%5B%5D=replacement%5B%5D");
130+
assertThat(result.param("quux")).isPresent().hasValue("corge+");
131+
assertThat(result.uri().toString())
132+
.hasToString("http://localhost/path?quux=corge%2B&baz=qux&foo%5B%5D=replacement%5B%5D");
130133
}
131134

132135
@Test

spring-cloud-gateway-server-mvc/src/test/resources/application-functionhandlerconfigtests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
spring.cloud.gateway.mvc:
1+
spring.cloud.gateway.server.webmvc:
22
routesMap:
33
testsimplefunction:
44
uri: fn:upper

spring-cloud-gateway-server-mvc/src/test/resources/application-propertiesbeandefinitionregistrartests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
spring.cloud.gateway.mvc:
1+
spring.cloud.gateway.server.webmvc:
22
routesMap:
33
route1:
44
uri: https://example1.com

0 commit comments

Comments
 (0)