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

判断用户是否存在bug #9

Open
chanris opened this issue Sep 14, 2024 · 0 comments
Open

判断用户是否存在bug #9

chanris opened this issue Sep 14, 2024 · 0 comments

Comments

@chanris
Copy link

chanris commented Sep 14, 2024

org/opengoofy/index12306/biz/userservice/service/impl/UserLoginServiceImpl.java
代码片段

    @Override
    public Boolean hasUsername(String username) {
        boolean hasUsername = userRegisterCachePenetrationBloomFilter.contains(username);
        if (hasUsername) {
            StringRedisTemplate instance = (StringRedisTemplate) distributedCache.getInstance();
            return instance.opsForSet().isMember(USER_REGISTER_REUSE_SHARDING + hashShardingIdx(username), username);
        }
        return true;
    }
  1. 当bloomFilter判断username为false,username一定不存在,则应该返回false;
  2. 并且,hasUsername为true时,应返回 !instance.opsForSet().isMember(USER_REGISTER_REUSE_SHARDING + hashShardingIdx(username), username);,表示username已复用;
  3. 此外,还有一种情况没有考虑,username不存在,但bloomFilter误判为true,此时isMember() 为 false,按 2. 的 逻辑为 true,实际应为 false;
    故感觉逻辑不正确,若我理解错误,请多指教。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant