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

Commit

Permalink
[Exclusion Hunter] Part 21: ModifyCollectionInEnhancedForLoop (#5795)
Browse files Browse the repository at this point in the history
* shady-removal

* fix

Co-authored-by: Glenn Sheasby <[email protected]>
  • Loading branch information
jeremyk-91 and gsheasby authored Dec 14, 2021
1 parent 14cc6a1 commit 16588ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
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 @@ -102,7 +102,6 @@ allprojects {
'FutureReturnValueIgnored',
'InlineFormatString',
'MixedMutabilityReturnType',
'ModifyCollectionInEnhancedForLoop',
'NarrowingCompoundAssignment',
'PreconditionsConstantMessage',
'PreconditionsInvalidPlaceholder',
Expand Down

0 comments on commit 16588ff

Please sign in to comment.