Skip to content

Commit

Permalink
Fix the bug for parsing with only non-param gateway rules
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Zhao <[email protected]>
  • Loading branch information
sczyh30 committed May 21, 2019
1 parent 7f2e98b commit 6e794b8
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ public Object[] parseParameterFor(String resource, T request, Predicate<GatewayF
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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6e794b8

Please sign in to comment.