Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

注解文档下 test 示例的问题 #1821

Closed
mathcompelte opened this issue Oct 27, 2020 · 4 comments
Closed

注解文档下 test 示例的问题 #1821

mathcompelte opened this issue Oct 27, 2020 · 4 comments
Labels
area/annotation Issues or PRs related to annotation support

Comments

@mathcompelte
Copy link

Issue Description

Type: bug report or feature request

Describe what happened (or what feature you want)

Describe what you expected to happen

How to reproduce it (as minimally and precisely as possible)

Tell us your environment

Anything else we need to know?

@sczyh30
Copy link
Member

sczyh30 commented Nov 5, 2020

可否详细描述下,配以例子

@JiangZian
Copy link
Contributor

Can you describe it in detail

@mathcompelte
Copy link
Author

可否详细描述下,配以例子

https://github.com/alibaba/Sentinel/wiki/%E6%B3%A8%E8%A7%A3%E6%94%AF%E6%8C%81
中文文档里面的TestService这个test()方法的参数列表没有和Fallback函数一样。该处代码有误。
public class TestService {

// 对应的 `handleException` 函数需要位于 `ExceptionUtil` 类中,并且必须为 static 函数.
@SentinelResource(value = "test", blockHandler = "handleException", blockHandlerClass = {ExceptionUtil.class})
public void test() {
    System.out.println("Test");
}

// 原函数
@SentinelResource(value = "hello", blockHandler = "exceptionHandler", fallback = "helloFallback")
public String hello(long s) {
    return String.format("Hello at %d", s);
}

// Fallback 函数,函数签名与原函数一致或加一个 Throwable 类型的参数.
public String helloFallback(long s) {
    return String.format("Halooooo %d", s);
}

// Block 异常处理函数,参数最后多一个 BlockException,其余与原函数一致.
public String exceptionHandler(long s, BlockException ex) {
    // Do some log here.
    ex.printStackTrace();
    return "Oops, error occurred at " + s;
}

}

@sczyh30
Copy link
Member

sczyh30 commented Nov 16, 2020

第一个 test 的例子的目的是演示 blockHandler 在其它类时的配置 (blockHandlerClass),独立于 hello 的示例。这里放在最前面容易导致误解,已进行调整。

@sczyh30 sczyh30 closed this as completed Nov 16, 2020
@sczyh30 sczyh30 added the area/annotation Issues or PRs related to annotation support label Nov 16, 2020
@sczyh30 sczyh30 changed the title 注解方式实现限流demo测试方法参数未和异常捕捉方法参数一致。导致限流不能被Handler和fallback处理。 注解文档下 test 示例的问题 Nov 16, 2020
CST11021 pushed a commit to CST11021/Sentinel that referenced this issue Nov 3, 2021
[ISSUE alibaba#1821]Fix the issue that MessageClientIDSetter#getIPFromID return wrong pid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/annotation Issues or PRs related to annotation support
Projects
None yet
Development

No branches or pull requests

3 participants