Use removeIf rather than Iterator-based removal

See gh-34762
pull/34975/head
SeasonPan 2 years ago committed by Stephane Nicoll
parent 5a6e7d1226
commit 0d13e31827

@ -109,13 +109,7 @@ public class CachingOperationInvoker implements OperationInvoker {
private void cleanExpiredCachedResponses(long accessTime) {
try {
Iterator<Entry<CacheKey, CachedResponse>> iterator = this.cachedResponses.entrySet().iterator();
while (iterator.hasNext()) {
Entry<CacheKey, CachedResponse> entry = iterator.next();
if (entry.getValue().isStale(accessTime, this.timeToLive)) {
iterator.remove();
}
}
this.cachedResponses.entrySet().removeIf(entry -> entry.getValue().isStale(accessTime, this.timeToLive));
}
catch (Exception ex) {
}

@ -182,13 +182,7 @@ class OnBeanCondition extends FilteringSpringBootCondition implements Configurat
for (String type : spec.getTypes()) {
Collection<String> typeMatches = getBeanNamesForType(classLoader, considerHierarchy, beanFactory, type,
parameterizedContainers);
Iterator<String> iterator = typeMatches.iterator();
while (iterator.hasNext()) {
String match = iterator.next();
if (beansIgnoredByType.contains(match) || ScopedProxyUtils.isScopedTarget(match)) {
iterator.remove();
}
}
typeMatches.removeIf(match -> beansIgnoredByType.contains(match) || ScopedProxyUtils.isScopedTarget(match));
if (typeMatches.isEmpty()) {
result.recordUnmatchedType(type);
}

Loading…
Cancel
Save