public boolean doCredentialsMatch(AuthenticationToken token, AuthenticationInfo info) {
        String username = (String) token.getPrincipal();
        AtomicInteger retryCount = passwordRetryCache.get(username);
        if (retryCount == null) {
            retryCount = new AtomicInteger(0);
            passwordRetryCache.put(username, retryCount);
        }
        if (retryCount.get() >= 5) {
            throw new ExcessiveAttemptsException("该账号已被锁定!");
        }
        boolean matches = super.doCredentialsMatch(token, info);
        if (!matches) {
            int number = 5 - retryCount.addAndGet(1);
            System.out.println(retryCount.get() + ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
            throw new ExcessiveAttemptsException("密码错误,还可以尝试" + number + "次!");
        }
        //clear retry count
        passwordRetryCache.remove(username);
        return true;
    }
当断点开启时,执行一行代码 retryCount 就+1
不打断点,就是正常。