Kaynağa Gözat

Fix the bug for parsing with only non-param gateway rules

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 5 yıl önce
ebeveyn
işleme
8d0bb691b3
3 değiştirilmiş dosya ile 9 ekleme ve 4 silme
  1. +2
    -2
      sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParser.java
  2. +6
    -1
      sentinel-adapter/sentinel-api-gateway-adapter-common/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParserTest.java
  3. +1
    -1
      sentinel-adapter/sentinel-spring-cloud-gateway-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/sc/SpringCloudGatewayParamParserTest.java

+ 2
- 2
sentinel-adapter/sentinel-api-gateway-adapter-common/src/main/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParser.java Dosyayı Görüntüle

@@ -62,10 +62,10 @@ public class GatewayParamParser<T> {
hasNonParamRule = true;
}
}
if (gatewayRules.isEmpty()) {
if (!hasNonParamRule && gatewayRules.isEmpty()) {
return new Object[0];
}
if (predSet.size() != 1 || predSet.contains(false)) {
if (predSet.size() > 1 || predSet.contains(false)) {
return new Object[0];
}
int size = hasNonParamRule ? gatewayRules.size() + 1 : gatewayRules.size();


+ 6
- 1
sentinel-adapter/sentinel-api-gateway-adapter-common/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/common/param/GatewayParamParserTest.java Dosyayı Görüntüle

@@ -70,10 +70,15 @@ public class GatewayParamParserTest {
.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


+ 1
- 1
sentinel-adapter/sentinel-spring-cloud-gateway-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/gateway/sc/SpringCloudGatewayParamParserTest.java Dosyayı Görüntüle

@@ -67,7 +67,7 @@ public class SpringCloudGatewayParamParserTest {

Object[] params = paramParser.parseParameterFor(routeId1, exchange,
e -> e.getResourceMode() == 0);
assertThat(params.length).isZero();
assertThat(params.length).isEqualTo(1);
}

@Test


Yükleniyor…
İptal
Kaydet