Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

[Exclusion Hunter] Part 21: ModifyCollectionInEnhancedForLoop #5795

Merged
merged 3 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,10 @@
import java.net.InetSocketAddress;
import java.time.Clock;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
Expand All @@ -54,17 +56,20 @@ public Blacklist(CassandraKeyValueServiceConfig config) {

void checkAndUpdate(Map<InetSocketAddress, CassandraClientPoolingContainer> pools) {
// Check blacklist and re-integrate or continue to wait as necessary
for (Map.Entry<InetSocketAddress, Long> blacklistedEntry : blacklist.entrySet()) {
Iterator<Entry<InetSocketAddress, Long>> blacklistIterator =
blacklist.entrySet().iterator();
while (blacklistIterator.hasNext()) {
Map.Entry<InetSocketAddress, Long> blacklistedEntry = blacklistIterator.next();
if (coolOffPeriodExpired(blacklistedEntry)) {
InetSocketAddress host = blacklistedEntry.getKey();
if (!pools.containsKey(host)) {
// Probably the pool changed underneath us
blacklist.remove(host);
blacklistIterator.remove();
log.info(
"Removing host {} from the blacklist as it wasn't found in the pool.",
SafeArg.of("host", CassandraLogHelper.host(host)));
} else if (isHostHealthy(pools.get(host))) {
blacklist.remove(host);
blacklistIterator.remove();
log.info(
"Added host {} back into the pool after a waiting period and successful health check.",
SafeArg.of("host", CassandraLogHelper.host(host)));
Expand Down
1 change: 0 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ allprojects {
'LogSafePreconditionsMessageFormat',
'MixedMutabilityReturnType',
'MockitoInternalUsage',
'ModifyCollectionInEnhancedForLoop',
'NarrowingCompoundAssignment',
'OverrideThrowableToString',
'PreconditionsConstantMessage',
Expand Down