diff --git a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java index 13789c4ce2..99cc2b08db 100644 --- a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java +++ b/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/trace/http/HttpExchangeTracer.java @@ -18,7 +18,6 @@ package org.springframework.boot.actuate.trace.http; import java.net.URI; import java.security.Principal; -import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -103,12 +102,7 @@ public class HttpExchangeTracer { return new LinkedHashMap<>(); } Map> headers = headersSupplier.get(); - Iterator keys = headers.keySet().iterator(); - while (keys.hasNext()) { - if (!headerPredicate.test(keys.next())) { - keys.remove(); - } - } + headers.keySet().removeIf(s -> !headerPredicate.test(s)); return headers; }