From 4b8829364e46ab533c425c88ab7e4d676f4c7ae3 Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Tue, 11 Apr 2023 16:29:43 +0200 Subject: [PATCH] Polish "Use removeIf rather than Iterator-based removal" See gh-34762 --- .../endpoint/invoker/cache/CachingOperationInvoker.java | 6 ++---- .../boot/autoconfigure/condition/OnBeanCondition.java | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) 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 aa8ae990d2..6e24168e62 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 @@ -1,5 +1,5 @@ /* - * Copyright 2012-2021 the original author or authors. + * Copyright 2012-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,9 +19,7 @@ package org.springframework.boot.actuate.endpoint.invoker.cache; import java.security.Principal; import java.time.Duration; import java.util.Arrays; -import java.util.Iterator; import java.util.Map; -import java.util.Map.Entry; import java.util.Objects; import reactor.core.publisher.Flux; @@ -109,7 +107,7 @@ public class CachingOperationInvoker implements OperationInvoker { private void cleanExpiredCachedResponses(long accessTime) { try { - this.cachedResponses.entrySet().removeIf(entry -> entry.getValue().isStale(accessTime, this.timeToLive)); + 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 98f94fa19e..248f68a3fe 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 @@ -24,7 +24,6 @@ import java.util.Collection; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; -import java.util.Iterator; import java.util.LinkedHashSet; import java.util.List; import java.util.Locale; @@ -182,7 +181,8 @@ class OnBeanCondition extends FilteringSpringBootCondition implements Configurat for (String type : spec.getTypes()) { Collection typeMatches = getBeanNamesForType(classLoader, considerHierarchy, beanFactory, type, parameterizedContainers); - typeMatches.removeIf(match -> beansIgnoredByType.contains(match) || ScopedProxyUtils.isScopedTarget(match)); + typeMatches + .removeIf((match) -> beansIgnoredByType.contains(match) || ScopedProxyUtils.isScopedTarget(match)); if (typeMatches.isEmpty()) { result.recordUnmatchedType(type); }