Skip to content

Commit 733ce03

Browse files
committed
Merge branch '4.0.x'
2 parents a26f652 + 8263985 commit 733ce03

File tree

5 files changed

+45
-28
lines changed

5 files changed

+45
-28
lines changed

spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/actuate/AbstractGatewayControllerEndpoint.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public AbstractGatewayControllerEndpoint(RouteDefinitionLocator routeDefinitionL
9696
List<GlobalFilter> globalFilters, List<GatewayFilterFactory> gatewayFilters,
9797
List<RoutePredicateFactory> routePredicates, RouteDefinitionWriter routeDefinitionWriter,
9898
RouteLocator routeLocator) {
99-
this(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates,
100-
routeDefinitionWriter, routeLocator, new WebEndpointProperties());
99+
this(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates, routeDefinitionWriter,
100+
routeLocator, new WebEndpointProperties());
101101
}
102102

103103
public AbstractGatewayControllerEndpoint(RouteDefinitionLocator routeDefinitionLocator,
@@ -126,8 +126,7 @@ Mono<List<GatewayEndpointInfo>> getEndpoints() {
126126
.collectList();
127127
}
128128

129-
private List<GatewayEndpointInfo> mergeEndpoints(List<GatewayEndpointInfo> listA,
130-
List<GatewayEndpointInfo> listB) {
129+
private List<GatewayEndpointInfo> mergeEndpoints(List<GatewayEndpointInfo> listA, List<GatewayEndpointInfo> listB) {
131130
Map<String, List<String>> mergedMap = new HashMap<>();
132131

133132
Stream.concat(listA.stream(), listB.stream()).forEach(e -> mergedMap

spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/actuate/GatewayControllerEndpoint.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ public GatewayControllerEndpoint(List<GlobalFilter> globalFilters, List<GatewayF
5050
List<RoutePredicateFactory> routePredicates, RouteDefinitionWriter routeDefinitionWriter,
5151
RouteLocator routeLocator, RouteDefinitionLocator routeDefinitionLocator,
5252
WebEndpointProperties webEndpointProperties) {
53-
super(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates,
54-
routeDefinitionWriter, routeLocator, webEndpointProperties);
53+
super(routeDefinitionLocator, globalFilters, gatewayFilters, routePredicates, routeDefinitionWriter,
54+
routeLocator, webEndpointProperties);
5555
}
5656

5757
@GetMapping("/routedefinitions")

spring-cloud-gateway-server/src/main/java/org/springframework/cloud/gateway/support/ShortcutConfigurable.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public Map<String, Object> normalize(Map<String, String> args, ShortcutConfigura
151151
// strip boolean flag if last entry is true or false
152152
int lastIdx = values.size() - 1;
153153
String lastValue = values.get(lastIdx);
154-
if (lastValue.equalsIgnoreCase("true") || lastValue.equalsIgnoreCase("false")) {
154+
if ("true".equalsIgnoreCase(lastValue) || "false".equalsIgnoreCase(lastValue) || lastValue == null) {
155155
values = values.subList(0, lastIdx);
156156
map.put(fieldOrder.get(1), getValue(parser, beanFactory, lastValue));
157157
}

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/actuate/GatewayControllerEndpointTests.java

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -70,29 +70,21 @@ public class GatewayControllerEndpointTests {
7070

7171
@Test
7272
public void testEndpoints() {
73-
testClient.get().uri("http://localhost:" + port + "/actuator/gateway").exchange()
74-
.expectStatus().isOk().expectBodyList(Map.class).consumeWith(result -> {
73+
testClient.get().uri("http://localhost:" + port + "/actuator/gateway").exchange().expectStatus().isOk()
74+
.expectBodyList(Map.class).consumeWith(result -> {
7575
List<Map> responseBody = result.getResponseBody();
7676
assertThat(responseBody).isNotEmpty();
77-
assertThat(responseBody).contains(
78-
Map.of("href", "/actuator/gateway/", "methods",
79-
List.of("GET")),
80-
Map.of("href", "/actuator/gateway/globalfilters", "methods",
81-
List.of("GET")),
82-
Map.of("href", "/actuator/gateway/refresh", "methods",
83-
List.of("POST")),
84-
Map.of("href", "/actuator/gateway/routedefinitions",
85-
"methods", List.of("GET")),
86-
Map.of("href", "/actuator/gateway/routefilters", "methods",
87-
List.of("GET")),
88-
Map.of("href", "/actuator/gateway/routepredicates", "methods",
89-
List.of("GET")),
90-
Map.of("href", "/actuator/gateway/routes", "methods",
91-
List.of("POST", "GET")),
92-
Map.of("href", "/actuator/gateway/routes/test-service",
93-
"methods", List.of("POST", "DELETE", "GET")),
94-
Map.of("href", "/actuator/gateway/routes/route_with_metadata",
95-
"methods", List.of("POST", "DELETE", "GET")));
77+
assertThat(responseBody).contains(Map.of("href", "/actuator/gateway/", "methods", List.of("GET")),
78+
Map.of("href", "/actuator/gateway/globalfilters", "methods", List.of("GET")),
79+
Map.of("href", "/actuator/gateway/refresh", "methods", List.of("POST")),
80+
Map.of("href", "/actuator/gateway/routedefinitions", "methods", List.of("GET")),
81+
Map.of("href", "/actuator/gateway/routefilters", "methods", List.of("GET")),
82+
Map.of("href", "/actuator/gateway/routepredicates", "methods", List.of("GET")),
83+
Map.of("href", "/actuator/gateway/routes", "methods", List.of("POST", "GET")),
84+
Map.of("href", "/actuator/gateway/routes/test-service", "methods",
85+
List.of("POST", "DELETE", "GET")),
86+
Map.of("href", "/actuator/gateway/routes/route_with_metadata", "methods",
87+
List.of("POST", "DELETE", "GET")));
9688
});
9789
}
9890

spring-cloud-gateway-server/src/test/java/org/springframework/cloud/gateway/support/ShortcutConfigurableTests.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,32 @@ public ShortcutType shortcutType() {
182182
}
183183
}
184184

185+
@Test
186+
public void testNormalizeGatherListTailFlagFlagIsNull() {
187+
parser = new SpelExpressionParser();
188+
ShortcutConfigurable shortcutConfigurable = new ShortcutConfigurable() {
189+
@Override
190+
public List<String> shortcutFieldOrder() {
191+
return Arrays.asList("values", "flag");
192+
}
193+
194+
@Override
195+
public ShortcutType shortcutType() {
196+
return ShortcutType.GATHER_LIST_TAIL_FLAG;
197+
}
198+
};
199+
Map<String, String> args = new HashMap<>();
200+
args.put("1", "val0");
201+
args.put("2", "val1");
202+
args.put("3", "val2");
203+
args.put("4", null);
204+
Map<String, Object> map = ShortcutType.GATHER_LIST_TAIL_FLAG.normalize(args, shortcutConfigurable, parser,
205+
this.beanFactory);
206+
assertThat(map).isNotNull().containsKey("values");
207+
assertThat((List) map.get("values")).containsExactly("val0", "val1", "val2");
208+
assertThat(map.get("flag")).isNull();
209+
}
210+
185211
@SpringBootConfiguration
186212
protected static class TestConfig {
187213

0 commit comments

Comments
 (0)