Fix hookOnCancel handing logic in SentinelReactorSubscriber (#1089)

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
Eric Zhao 2019-10-23 19:35:14 +08:00 committed by GitHub
parent b0905547ff
commit b05502f8c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -155,7 +155,7 @@ public class SentinelReactorSubscriber<T> extends InheritableBaseSubscriber<T> {
@Override
protected void hookOnCancel() {
tryCompleteEntry();
}
private boolean tryCompleteEntry() {

View File

@ -162,6 +162,28 @@ public class MonoSentinelOperatorIntegrationTest {
assertEquals(1, cn.totalException());
}
@Test
public void testMultipleReactorTransformerLatterFlowControl() {
String resourceName1 = createResourceName("testMultipleReactorTransformerLatterFlowControl1");
String resourceName2 = createResourceName("testMultipleReactorTransformerLatterFlowControl2");
FlowRuleManager.loadRules(Collections.singletonList(
new FlowRule(resourceName2).setCount(0)
));
StepVerifier.create(Mono.just(2)
.transform(new SentinelReactorTransformer<>(resourceName1))
.transform(new SentinelReactorTransformer<>(resourceName2)))
.expectError(BlockException.class)
.verify();
ClusterNode cn1 = ClusterBuilderSlot.getClusterNode(resourceName1);
assertNotNull(cn1);
ClusterNode cn2 = ClusterBuilderSlot.getClusterNode(resourceName2);
assertNotNull(cn2);
assertEquals(1, cn2.blockRequest());
assertEquals(1, cn1.totalSuccess());
FlowRuleManager.loadRules(new ArrayList<>());
}
private String createResourceName(String resourceName) {
return "reactor_test_mono_" + resourceName;
}