diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvoker.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvoker.java index 5507f4b7f8..aa8ae990d2 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvoker.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/invoker/cache/CachingOperationInvoker.java @@ -109,13 +109,7 @@ public class CachingOperationInvoker implements OperationInvoker { private void cleanExpiredCachedResponses(long accessTime) { try { - Iterator> iterator = this.cachedResponses.entrySet().iterator(); - while (iterator.hasNext()) { - Entry 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) { } diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java index edefe23f96..98f94fa19e 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/condition/OnBeanCondition.java @@ -182,13 +182,7 @@ class OnBeanCondition extends FilteringSpringBootCondition implements Configurat for (String type : spec.getTypes()) { Collection typeMatches = getBeanNamesForType(classLoader, considerHierarchy, beanFactory, type, parameterizedContainers); - Iterator 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); }