Source:
public void logMessage(long timestampMilis, String user, String ip) { checkCounter(timestampMilis); long timestampSeconds = timestampMilis / 1000; if (!m_timeBucketQueue.isEmpty() && m_timeBucketQueue.peekLast().m_ts == timestampSeconds) { TimeBucket bucket = m_timeBucketQueue.peekLast(); int bucketUserFailedCount = bucket.m_userFailedAttempts.getOrDefault(user, 0) + 1; bucket.m_userFailedAttempts.put(user,bucketUserFailedCount); int bucketIPFailedCount = bucket.m_ipFailedAttempts.getOrDefault(ip, 0) + 1; bucket.m_ipFailedAttempts.put(ip, bucketIPFailedCount); bucket.m_totalFailedAttempts++; } else { TimeBucket bucket = new TimeBucket(); bucket.m_userFailedAttempts.put(user, 1); bucket.m_ipFailedAttempts.put(ip, 1); bucket.m_ts = timestampSeconds; bucket.m_totalFailedAttempts = 1; m_timeBucketQueue.offer(bucket); } int userFailedCount = m_userFailedAttempts.getOrDefault(user,0) + 1; String messageFormat = "User "+ user +" failed to authenticate %d times in last minute"; RateLimitedLogger.tryLogForMessage(timestampMilis, 10000, TimeUnit.MILLISECONDS, authLog, Level.WARN, messageFormat, userFailedCount); m_userFailedAttempts.put(user, userFailedCount); int ipFailedCount = m_ipFailedAttempts.getOrDefault(ip, 0) + 1; messageFormat = "IP address "+ ip +" failed to authenticate %d times in last minute"; RateLimitedLogger.tryLogForMessage(timestampMilis, 10000, TimeUnit.MILLISECONDS, authLog, Level.WARN, messageFormat, ipFailedCount); m_ipFailedAttempts.put(ip, ipFailedCount); m_totalFailedAttempts++; messageFormat = "Total failed authentication: %d times in last minute"; RateLimitedLogger.tryLogForMessage(timestampMilis, ONE_MINUTE_IN_MILLIS, TimeUnit.MILLISECONDS, authLog, Level.WARN, messageFormat, m_totalFailedAttempts); }

Target:
public void logMessage(long timestampMilis, String user, String ip) { checkCounter(timestampMilis); long timestampSeconds = timestampMilis / 1000; if (!m_timeBucketQueue.isEmpty() && m_timeBucketQueue.peekLast().m_ts == timestampSeconds) { TimeBucket bucket = m_timeBucketQueue.peekLast(); int bucketUserFailedCount = bucket.m_userFailedAttempts.getOrDefault(user, 0) + 1; bucket.m_userFailedAttempts.put(user,bucketUserFailedCount); int bucketIPFailedCount = bucket.m_ipFailedAttempts.getOrDefault(ip, 0) + 1; bucket.m_ipFailedAttempts.put(ip, bucketIPFailedCount); bucket.m_totalFailedAttempts++; } else { TimeBucket bucket = new TimeBucket(); bucket.m_userFailedAttempts.put(user, 1); bucket.m_ipFailedAttempts.put(ip, 1); bucket.m_ts = timestampSeconds; bucket.m_totalFailedAttempts = 1; m_timeBucketQueue.offer(bucket); } int userFailedCount = m_userFailedAttempts.getOrDefault(user,0) + 1; String messageFormat = "User "+ user +" failed to authenticate %d times in last minute"; RateLimitedLogger.tryLogForMessage(timestampMilis, 10000, TimeUnit.MILLISECONDS, authLog, Level.INFO, messageFormat, userFailedCount); m_userFailedAttempts.put(user, userFailedCount); int ipFailedCount = m_ipFailedAttempts.getOrDefault(ip, 0) + 1; messageFormat = "IP address "+ ip +" failed to authenticate %d times in last minute"; RateLimitedLogger.tryLogForMessage(timestampMilis, 10000, TimeUnit.MILLISECONDS, authLog, Level.INFO, messageFormat, ipFailedCount); m_ipFailedAttempts.put(ip, ipFailedCount); m_totalFailedAttempts++; messageFormat = "Total failed logins: %d in last minute"; RateLimitedLogger.tryLogForMessage(timestampMilis, ONE_MINUTE_IN_MILLIS, TimeUnit.MILLISECONDS, authLog, Level.INFO, messageFormat, m_totalFailedAttempts); }