alibaba / alibaba/jetcache

使用jetcache时,其他没加@cache注解的接口会污染到加了@cache的接口是什么原因?

Open
#925 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
5.6k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

我的代码

`

/**
* 获取配置
*/
@PostMapping("/mix")
@Cached(name = "PublicController.mix", expire = 60, cacheType = CacheType.LOCAL)
@CachePenetrationProtect
public ResponseResult mix() {

CheckValidateConfigDTO objConfig = ApolloUtils.parseObject(ApolloConstants.UPEX_MIX_NAME_SPACE, ApolloConstants.CHECK_VALIDATE_CONFIG, CheckValidateConfigDTO.class);
HashMap resultMap = Maps.newHashMap();
JSONObject jsonObject = ApolloUtils.getObjConfig(ApolloConstants.UPEX_MIX_NAME_SPACE, ApolloConstants.WAF_CONFIG_PRE, JSONObject.class);

JSONObject config = objConfig.getConfig();
config.put("channelName", "geetest");
resultMap.put("validate", config);
resultMap.put("wafConfig", jsonObject);
log.info("public config resultMap:{}", JSON.toJSONString(resultMap));
return ResultUtils.success(resultMap);

}

/**
* 获取配置
*/
@PostMapping("/mixV2")
public ResponseResult mixV2() {

CheckValidateConfigDTO objConfig = ApolloUtils.parseObject(ApolloConstants.UPEX_MIX_NAME_SPACE, ApolloConstants.CHECK_VALIDATE_CONFIG, CheckValidateConfigDTO.class);
HashMap resultMap = Maps.newHashMap();
JSONObject jsonObject = ApolloUtils.getObjConfig(ApolloConstants.UPEX_MIX_NAME_SPACE, ApolloConstants.WAF_CONFIG_PRE, JSONObject.class);

JSONObject config = objConfig.getConfig();
config.put("channelName", "aliyun");
resultMap.put("validate", config);
resultMap.put("wafConfig", jsonObject);
log.info("public configV2 resultMap:{}", JSON.toJSONString(resultMap));
return ResultUtils.success(resultMap);

}
`

这里先多次调用mixV2接口,再调用mix接口,返回结果channelName竟然偶然会返回aliyun,请问是否在使用apollo的时候触发了jetcache的bug?
{
"code": "00000",
"data": {
"validate": {
"channelName": "aliyun",
"loginNewNeedValidate": true
},
"wafConfig": {
"open": true,
"integrationUrl": "https://xxxxx"
}
},
"msg": "success",
"requestTime": "1726039268846"
}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the two controller methods shown in the issue, especially the @Cached and @CachePenetrationProtect annotations on mix versus the unannotated mixV2 method. Reproduce the sequence of repeated mixV2 calls followed by mix, then inspect JetCache's method-key and interception behavior. Done means the cause of the cross-endpoint result contamination is identified and a regression test or clearly scoped fix is defined.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.