diff --git a/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParser.java b/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParser.java index fe51c4c572..f326468b68 100644 --- a/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParser.java +++ b/sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParser.java @@ -62,10 +62,10 @@ public Object[] parseParameterFor(String resource, T request, Predicate 1 || predSet.contains(false)) { return new Object[0]; } int size = hasNonParamRule ? gatewayRules.size() + 1 : gatewayRules.size(); diff --git a/sentinel-adapter/sentinel-api-gateway-adapter-common/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParserTest.java b/sentinel-adapter/sentinel-api-gateway-adapter-common/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParserTest.java index 9fc8dc0e91..7edc7844ed 100644 --- a/sentinel-adapter/sentinel-api-gateway-adapter-common/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParserTest.java +++ b/sentinel-adapter/sentinel-api-gateway-adapter-common/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParserTest.java @@ -70,10 +70,15 @@ public void testParseParametersNoParamItem() { .setCount(5) .setIntervalSec(1) ); + rules.add(new GatewayFlowRule(routeId1) + .setCount(10) + .setControlBehavior(2) + .setMaxQueueingTimeoutMs(1000) + ); GatewayRuleManager.loadRules(rules); Object[] params = parser.parseParameterFor(routeId1, request, routeIdPredicate); - assertThat(params.length).isZero(); + assertThat(params.length).isEqualTo(1); } @Test diff --git a/sentinel-adapter/sentinel-spring-cloud-gateway-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/sc/SpringCloudGatewayParamParserTest.java b/sentinel-adapter/sentinel-spring-cloud-gateway-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/sc/SpringCloudGatewayParamParserTest.java index 5b9ca980ee..a28240e0b2 100644 --- a/sentinel-adapter/sentinel-spring-cloud-gateway-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/sc/SpringCloudGatewayParamParserTest.java +++ b/sentinel-adapter/sentinel-spring-cloud-gateway-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/sc/SpringCloudGatewayParamParserTest.java @@ -67,7 +67,7 @@ public void testParseParametersNoParamItem() { Object[] params = paramParser.parseParameterFor(routeId1, exchange, e -> e.getResourceMode() == 0); - assertThat(params.length).isZero(); + assertThat(params.length).isEqualTo(1); } @Test