Skip to content

Commit 7b328fa

Browse files
committed
Use LinkedHashMap for CORS configurations in CorsGatewayFilterApplicationListener to preserve insertion order. Fixes GH-3805.
Signed-off-by: Yavor Chamov <[email protected]>
1 parent efa9e1d commit 7b328fa

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/filter/cors/CorsGatewayFilterApplicationListenerTests.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import org.mockito.junit.jupiter.MockitoExtension;
3232
import reactor.core.publisher.Flux;
3333

34-
import org.springframework.boot.autoconfigure.web.reactive.WebFluxProperties;
3534
import org.springframework.cloud.gateway.config.GlobalCorsProperties;
3635
import org.springframework.cloud.gateway.event.RefreshRoutesResultEvent;
3736
import org.springframework.cloud.gateway.handler.RoutePredicateHandlerMapping;
@@ -107,10 +106,8 @@ void testOnApplicationEvent_preservesInsertionOrder_withRealRoutes() {
107106
globalCorsProperties.getCorsConfigurations().put(GLOBAL_PATH_1, createCorsConfig(ORIGIN_GLOBAL_1));
108107
globalCorsProperties.getCorsConfigurations().put(GLOBAL_PATH_2, createCorsConfig(ORIGIN_GLOBAL_2));
109108

110-
WebFluxProperties webFluxProperties = new WebFluxProperties();
111-
112-
Route route1 = buildRoute(ROUTE_ID_1, ROUTE_PATH_1, ORIGIN_ROUTE_1, webFluxProperties);
113-
Route route2 = buildRoute(ROUTE_ID_2, ROUTE_PATH_2, ORIGIN_ROUTE_2, webFluxProperties);
109+
Route route1 = buildRoute(ROUTE_ID_1, ROUTE_PATH_1, ORIGIN_ROUTE_1);
110+
Route route2 = buildRoute(ROUTE_ID_2, ROUTE_PATH_2, ORIGIN_ROUTE_2);
114111

115112
when(routeLocator.getRoutes()).thenReturn(Flux.just(route1, route2));
116113

@@ -141,12 +138,12 @@ private CorsConfiguration createCorsConfig(String origin) {
141138
return config;
142139
}
143140

144-
private Route buildRoute(String id, String path, String allowedOrigin, WebFluxProperties webFluxProperties) {
141+
private Route buildRoute(String id, String path, String allowedOrigin) {
145142

146143
return Route.async()
147144
.id(id)
148145
.uri(ROUTE_URI)
149-
.predicate(new PathRoutePredicateFactory(webFluxProperties)
146+
.predicate(new PathRoutePredicateFactory()
150147
.apply(config -> config.setPatterns(List.of(path))))
151148
.metadata(METADATA_KEY, Map.of(ALLOWED_ORIGINS_KEY, List.of(allowedOrigin)))
152149
.build();

0 commit comments

Comments
 (0)