Use removeIf rather than Iterator-based removal

See gh-34762
This commit is contained in:
SeasonPan 2023-03-25 22:50:52 +08:00 committed by Stephane Nicoll
parent 5a6e7d1226
commit 0d13e31827
2 changed files with 2 additions and 14 deletions

View File

@ -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) {
}

View File

@ -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);
}