From bd6e1593cf8d45e546bf99162ee0f122d87cd102 Mon Sep 17 00:00:00 2001 From: luffy <514896097@qq.com> Date: Fri, 5 May 2023 23:51:45 +0800 Subject: [PATCH 1/3] Add global fallback support for AspectJ annotation extension --- .../sentinel/annotation/SentinelResource.java | 5 ++++ .../fallback/DefaultGlobalFallback.java | 16 +++++++++++++ .../sentinel/fallback/IGlobalFallback.java | 15 ++++++++++++ .../AbstractSentinelAspectSupport.java | 14 +++++++++++ .../aspectj/ResourceMetadataRegistry.java | 24 +++++++++++++++++++ .../aspectj/SentinelResourceAspect.java | 4 ++-- .../aspectj/ResourceMetadataRegistryTest.java | 11 +++++++++ .../SentinelAnnotationIntegrationTest.java | 13 ++++++++++ .../fallback/AnnotationGlobalFallback.java | 18 ++++++++++++++ .../integration/service/FooService.java | 21 +++++++++++++++- 10 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java create mode 100644 sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java create mode 100644 sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/fallback/AnnotationGlobalFallback.java diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/annotation/SentinelResource.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/annotation/SentinelResource.java index fe1ab396dd..87220b6681 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/annotation/SentinelResource.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/annotation/SentinelResource.java @@ -16,6 +16,8 @@ package com.alibaba.csp.sentinel.annotation; import com.alibaba.csp.sentinel.EntryType; +import com.alibaba.csp.sentinel.fallback.DefaultGlobalFallback; +import com.alibaba.csp.sentinel.fallback.IGlobalFallback; import java.lang.annotation.*; @@ -77,6 +79,9 @@ */ String defaultFallback() default ""; + Class globalFallback() default DefaultGlobalFallback.class; + + /** * The {@code fallback} is located in the same class with the original method by default. * However, if some methods share the same signature and intend to set the same fallback, diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java new file mode 100644 index 0000000000..435161e4d1 --- /dev/null +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java @@ -0,0 +1,16 @@ +package com.alibaba.csp.sentinel.fallback; + +import java.lang.reflect.Method; + +/** + * @author luffy + * @version 1.0 + * @date 2023/5/5 11:02 下午 + */ +public class DefaultGlobalFallback implements IGlobalFallback { + + @Override + public Object handle(Method originalMethod, Object[] args, Throwable t) throws Throwable{ + throw t; + } +} diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java new file mode 100644 index 0000000000..b7d75411ff --- /dev/null +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java @@ -0,0 +1,15 @@ +package com.alibaba.csp.sentinel.fallback; + +import java.lang.reflect.Method; + +/** + * @author luffy + * @version 1.0 + * @date 2023/5/5 10:56 上午 + */ +public interface IGlobalFallback { + + + Object handle(Method originalMethod, Object[] args, Throwable t) throws Throwable; + +} diff --git a/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/AbstractSentinelAspectSupport.java b/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/AbstractSentinelAspectSupport.java index b0c38e2e36..f563553175 100644 --- a/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/AbstractSentinelAspectSupport.java +++ b/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/AbstractSentinelAspectSupport.java @@ -17,6 +17,7 @@ import com.alibaba.csp.sentinel.Tracer; import com.alibaba.csp.sentinel.annotation.SentinelResource; +import com.alibaba.csp.sentinel.fallback.IGlobalFallback; import com.alibaba.csp.sentinel.log.RecordLog; import com.alibaba.csp.sentinel.slots.block.BlockException; import com.alibaba.csp.sentinel.util.MethodUtil; @@ -85,6 +86,19 @@ protected Object handleFallback(ProceedingJoinPoint pjp, SentinelResource annota return handleFallback(pjp, annotation.fallback(), annotation.defaultFallback(), annotation.fallbackClass(), ex); } + protected Object handleGlobalFallback(ProceedingJoinPoint pjp, + Class globalFallbackClazz, + Throwable ex) throws Throwable { + Object[] originArgs = pjp.getArgs(); + Method originMethod = resolveMethod(pjp); + IGlobalFallback globalFallback = ResourceMetadataRegistry.lookupGlobalHandler(globalFallbackClazz); + if(globalFallback == null){ + globalFallback = ResourceMetadataRegistry.updateGlobalFallBackFor(globalFallbackClazz); + } + return globalFallback.handle(originMethod,originArgs,ex); + } + + protected Object handleFallback(ProceedingJoinPoint pjp, String fallback, String defaultFallback, Class[] fallbackClass, Throwable ex) throws Throwable { Object[] originArgs = pjp.getArgs(); diff --git a/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistry.java b/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistry.java index c4988130a8..2e9f6dc840 100644 --- a/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistry.java +++ b/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistry.java @@ -19,6 +19,7 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import com.alibaba.csp.sentinel.fallback.IGlobalFallback; import com.alibaba.csp.sentinel.util.StringUtil; /** @@ -32,6 +33,9 @@ final class ResourceMetadataRegistry { private static final Map DEFAULT_FALLBACK_MAP = new ConcurrentHashMap<>(); private static final Map BLOCK_HANDLER_MAP = new ConcurrentHashMap<>(); + private static final Map GLOBAL_FALLBACK_MAP = new ConcurrentHashMap<>(); + + static MethodWrapper lookupFallback(Class clazz, String name) { return FALLBACK_MAP.get(getKey(clazz, name)); } @@ -44,6 +48,10 @@ static MethodWrapper lookupBlockHandler(Class clazz, String name) { return BLOCK_HANDLER_MAP.get(getKey(clazz, name)); } + static IGlobalFallback lookupGlobalHandler(Class clazz){ + return GLOBAL_FALLBACK_MAP.get(clazz.getCanonicalName()); + } + static void updateFallbackFor(Class clazz, String name, Method method) { if (clazz == null || StringUtil.isBlank(name)) { throw new IllegalArgumentException("Bad argument"); @@ -65,6 +73,22 @@ static void updateBlockHandlerFor(Class clazz, String name, Method method) { BLOCK_HANDLER_MAP.put(getKey(clazz, name), MethodWrapper.wrap(method)); } + static IGlobalFallback updateGlobalFallBackFor(Class clazz){ + if(clazz==null){ + throw new IllegalArgumentException("Bad argument"); + } + IGlobalFallback instance = null; + try{ + instance = clazz.newInstance(); + } catch (IllegalAccessException e) { + throw new IllegalArgumentException("Bad argument"); + } catch (InstantiationException e) { + throw new IllegalArgumentException("Bad argument"); + } + GLOBAL_FALLBACK_MAP.put(clazz.getCanonicalName(),instance); + return instance; + } + private static String getKey(Class clazz, String name) { return String.format("%s:%s", clazz.getCanonicalName(), name); } diff --git a/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.java b/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.java index 3e1a9d680c..9342aadc81 100644 --- a/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.java +++ b/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.java @@ -68,8 +68,8 @@ public Object invokeResourceWithSentinel(ProceedingJoinPoint pjp) throws Throwab return handleFallback(pjp, annotation, ex); } - // No fallback function can handle the exception, so throw it out. - throw ex; + // Global fallback function handle the exception. + return handleGlobalFallback(pjp,annotation.globalFallback(),ex); } finally { if (entry != null) { entry.exit(1, pjp.getArgs()); diff --git a/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistryTest.java b/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistryTest.java index eac25b91e0..837398814f 100644 --- a/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistryTest.java +++ b/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistryTest.java @@ -15,6 +15,7 @@ */ package com.alibaba.csp.sentinel.annotation.aspectj; +import com.alibaba.csp.sentinel.annotation.aspectj.integration.fallback.AnnotationGlobalFallback; import com.alibaba.csp.sentinel.annotation.aspectj.integration.service.FooService; import org.junit.After; import org.junit.Before; @@ -73,6 +74,16 @@ public void testUpdateThenLookupBlockHandler() { assertThat(wrapper.getMethod()).isSameAs(method); } + @Test + public void testUpdateThenLookupGlobalFallback() { + Class clazz = AnnotationGlobalFallback.class; + assertThat(ResourceMetadataRegistry.lookupGlobalHandler(clazz)).isNull(); + + ResourceMetadataRegistry.updateGlobalFallBackFor(clazz); + assertThat(ResourceMetadataRegistry.lookupGlobalHandler(clazz)).isNotNull(); + + } + @Test(expected = IllegalArgumentException.class) public void testUpdateBlockHandlerBadArgument() { ResourceMetadataRegistry.updateBlockHandlerFor(null, "sxs", String.class.getMethods()[0]); diff --git a/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/SentinelAnnotationIntegrationTest.java b/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/SentinelAnnotationIntegrationTest.java index e5da0413f1..462bca9ec0 100644 --- a/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/SentinelAnnotationIntegrationTest.java +++ b/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/SentinelAnnotationIntegrationTest.java @@ -230,6 +230,19 @@ public void testFallBackPrivateMethod() throws Exception { assertThat(fooService.fooWithPrivateFallback(2221)).isEqualTo("Oops, 2221"); } + @Test + public void testAnnotationGlobalFallback() throws Exception { + assertThat(fooService.fooWithAnnotationGlobalFallback(1)).isEqualTo("Hello for 1"); + // Fallback should take effect. + assertThat(fooService.fooWithAnnotationGlobalFallback(5758)).isEqualTo("AnnotationGlobalFallback"); + + } + + @Test(expected = IllegalAccessException.class) + public void testDefaultGlobalFallback() throws Exception { + fooService.fooWithDefaultGlobalFallback(5758); + } + @Before public void setUp() throws Exception { FlowRuleManager.loadRules(new ArrayList()); diff --git a/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/fallback/AnnotationGlobalFallback.java b/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/fallback/AnnotationGlobalFallback.java new file mode 100644 index 0000000000..ff8e6acabd --- /dev/null +++ b/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/fallback/AnnotationGlobalFallback.java @@ -0,0 +1,18 @@ +package com.alibaba.csp.sentinel.annotation.aspectj.integration.fallback; + +import com.alibaba.csp.sentinel.fallback.IGlobalFallback; + +import java.lang.reflect.Method; + +/** + * @author luffy + * @version 1.0 + * @date 2023/5/5 5:18 下午 + */ +public class AnnotationGlobalFallback implements IGlobalFallback { + + @Override + public Object handle(Method originalMethod, Object[] args, Throwable t) throws Throwable{ + return "AnnotationGlobalFallback"; + } +} diff --git a/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/service/FooService.java b/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/service/FooService.java index 3505c7e80d..95307c7a3b 100644 --- a/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/service/FooService.java +++ b/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/integration/service/FooService.java @@ -16,8 +16,8 @@ package com.alibaba.csp.sentinel.annotation.aspectj.integration.service; import com.alibaba.csp.sentinel.annotation.SentinelResource; +import com.alibaba.csp.sentinel.annotation.aspectj.integration.fallback.AnnotationGlobalFallback; import com.alibaba.csp.sentinel.slots.block.BlockException; -import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException; import org.springframework.stereotype.Service; @@ -53,6 +53,25 @@ public String fooWithFallback(int i) throws Exception { return "Hello for " + i; } + @SentinelResource(value = "apiFooWithFallback", globalFallback = AnnotationGlobalFallback.class, + exceptionsToTrace = {IllegalArgumentException.class}) + public String fooWithAnnotationGlobalFallback(int i) throws Exception { + if (i == 5758) { + throw new IllegalAccessException(); + } + return "Hello for " + i; + } + + @SentinelResource(value = "apiFooWithDefaultFallback",exceptionsToTrace = {IllegalArgumentException.class}) + public String fooWithDefaultGlobalFallback(int i) throws Exception { + if (i == 5758) { + throw new IllegalAccessException(); + } + return "Hello for " + i; + } + + + @SentinelResource(value = "apiAnotherFooWithDefaultFallback", defaultFallback = "globalDefaultFallback", fallbackClass = {FooUtil.class}) public String anotherFoo(int i) { From 789e74a0d22a69cd481de329ea85578f7c84b5ef Mon Sep 17 00:00:00 2001 From: luffy <514896097@qq.com> Date: Sat, 6 May 2023 09:48:15 +0800 Subject: [PATCH 2/3] fix unit test failure bugs --- .../csp/sentinel/fallback/DefaultGlobalFallback.java | 4 ++-- .../com/alibaba/csp/sentinel/fallback/IGlobalFallback.java | 4 ++-- .../annotation/aspectj/ResourceMetadataRegistry.java | 7 +++++++ .../annotation/aspectj/ResourceMetadataRegistryTest.java | 2 ++ 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java index 435161e4d1..ace8f4b170 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java @@ -3,9 +3,9 @@ import java.lang.reflect.Method; /** + * Default global fallback + * * @author luffy - * @version 1.0 - * @date 2023/5/5 11:02 下午 */ public class DefaultGlobalFallback implements IGlobalFallback { diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java index b7d75411ff..0491caf6af 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java @@ -3,9 +3,9 @@ import java.lang.reflect.Method; /** + * Global fallback interface + * * @author luffy - * @version 1.0 - * @date 2023/5/5 10:56 上午 */ public interface IGlobalFallback { diff --git a/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistry.java b/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistry.java index 2e9f6dc840..de82256f1a 100644 --- a/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistry.java +++ b/sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistry.java @@ -106,4 +106,11 @@ static void clearFallbackMap() { static void clearBlockHandlerMap() { BLOCK_HANDLER_MAP.clear(); } + + /** + * Only for internal test. + */ + static void clearGlobalHandlerMap(){ + GLOBAL_FALLBACK_MAP.clear(); + } } diff --git a/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistryTest.java b/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistryTest.java index 837398814f..2d8b7a000e 100644 --- a/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistryTest.java +++ b/sentinel-extension/sentinel-annotation-aspectj/src/test/java/com/alibaba/csp/sentinel/annotation/aspectj/ResourceMetadataRegistryTest.java @@ -34,12 +34,14 @@ public class ResourceMetadataRegistryTest { public void setUp() throws Exception { ResourceMetadataRegistry.clearBlockHandlerMap(); ResourceMetadataRegistry.clearFallbackMap(); + ResourceMetadataRegistry.clearGlobalHandlerMap(); } @After public void tearDown() throws Exception { ResourceMetadataRegistry.clearBlockHandlerMap(); ResourceMetadataRegistry.clearFallbackMap(); + ResourceMetadataRegistry.clearGlobalHandlerMap(); } @Test From 3fb3244cd26869f687d7c7ccc961272fbac7bd8f Mon Sep 17 00:00:00 2001 From: luffy <514896097@qq.com> Date: Tue, 9 May 2023 10:42:03 +0800 Subject: [PATCH 3/3] add javadoc and prepend license header --- .../sentinel/annotation/SentinelResource.java | 7 ++++++ .../fallback/DefaultGlobalFallback.java | 15 ++++++++++++ .../sentinel/fallback/IGlobalFallback.java | 24 ++++++++++++++++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/annotation/SentinelResource.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/annotation/SentinelResource.java index 87220b6681..c11f4fd396 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/annotation/SentinelResource.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/annotation/SentinelResource.java @@ -79,6 +79,13 @@ */ String defaultFallback() default ""; + + /** + * The {@code globalFallback} is used as the global fallback handler class. + * The returned class should implement the {@link IGlobalFallback} interface. + * If no specific global fallback handler is provided, the default {@link DefaultGlobalFallback} class will be used. + * @return The class that serves as the global fallback handler. + */ Class globalFallback() default DefaultGlobalFallback.class; diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java index ace8f4b170..a12e1d0d93 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/DefaultGlobalFallback.java @@ -1,3 +1,18 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.alibaba.csp.sentinel.fallback; import java.lang.reflect.Method; diff --git a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java index 0491caf6af..5fb744ccc5 100644 --- a/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java +++ b/sentinel-core/src/main/java/com/alibaba/csp/sentinel/fallback/IGlobalFallback.java @@ -1,3 +1,18 @@ +/* + * Copyright 1999-2018 Alibaba Group Holding Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package com.alibaba.csp.sentinel.fallback; import java.lang.reflect.Method; @@ -9,7 +24,14 @@ */ public interface IGlobalFallback { - + /** + * + * @param originalMethod the original method called + * @param args The parameters of the method that was originally called + * @param t The exception thrown by the method originally called + * @return The result of the global fallback handler execution + * @throws Throwable + */ Object handle(Method originalMethod, Object[] args, Throwable t) throws Throwable; }