这个熔断似乎并不生效,熔断时长无效。 浏览器一直刷新请求该接口,虽然可以跳到熔断方法内(但是设定的熔断时间为 70秒并没有生效,再次刷新,又重新正常返回。)
- Dominant language
- Java
- Stars
- 23.1k
- Forks
- 8.1k
- PR merge metrics
- No merged PRs in 30d
Description
```java
/**
* 获取当前用户信息
*/
//@InnerAuth
@GetMapping("/info/{username}")
@SentinelResource(value = "ruoyi-system", fallback = "selectUserByNameFallback")
public Object info(@PathVariable("username") String username)
{
int count = atomicInteger.getAndIncrement();//先取值,再递增
if (count %2 == 0) {
int x = 1/0;
}
//return userService.selectUserByName(username);
return "aaaaa";
}
// 服务流量控制处理,参数最后多一个 BlockException,其余与原函数一致。
public Object selectUserByNameBlockHandler(String username)
{
System.out.println("selectUserByNameBlockHandler异常信息");
return "{\"code\":\"500\",\"msg\": \"" + username + "服务流量控制处理\"}";
}
// 服务熔断降级处理,函数签名与原函数一致或加一个 Throwable 类型的参数
public Object selectUserByNameFallback(String username, Throwable throwable)
{
System.out.println("selectUserByNameFallback异常信息:" + throwable.getMessage());
return "{\"code\":\"500\",\"msg\": \"" + username + "服务熔断降级处理\"}";
}
```
Contributor guide
Research direction
Start with the annotated info endpoint and its SentinelResource fallback methods shown in the report. Reproduce the alternating exception behavior while checking the Sentinel circuit-breaker settings, especially the stated 70-second duration. Done means the configured duration is respected across repeated requests, or the missing configuration is identified and documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, distributed-systems
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100