Sfoglia il codice sorgente

Fix hookOnCancel handing logic in SentinelReactorSubscriber (#1089)

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao GitHub 5 anni fa
parent
commit
b05502f8c2
Non sono state trovate chiavi note per questa firma nel database ID Chiave GPG: 4AEE18F83AFDEB23
2 ha cambiato i file con 23 aggiunte e 1 eliminazioni
  1. +1
    -1
      sentinel-adapter/sentinel-reactor-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/reactor/SentinelReactorSubscriber.java
  2. +22
    -0
      sentinel-adapter/sentinel-reactor-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/reactor/MonoSentinelOperatorIntegrationTest.java

+ 1
- 1
sentinel-adapter/sentinel-reactor-adapter/src/main/java/com/alibaba/csp/sentinel/adapter/reactor/SentinelReactorSubscriber.java Vedi File

@@ -155,7 +155,7 @@ public class SentinelReactorSubscriber<T> extends InheritableBaseSubscriber<T> {

@Override
protected void hookOnCancel() {
tryCompleteEntry();
}

private boolean tryCompleteEntry() {


+ 22
- 0
sentinel-adapter/sentinel-reactor-adapter/src/test/java/com/alibaba/csp/sentinel/adapter/reactor/MonoSentinelOperatorIntegrationTest.java Vedi 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;
}

Loading…
Annulla
Salva