From 01a57a72198f6181d8e9c85c726259d326fc8fb3 Mon Sep 17 00:00:00 2001 From: Sam Brannen <104798+sbrannen@users.noreply.github.com> Date: Wed, 14 Jan 2026 13:47:44 +0100 Subject: [PATCH] Simplify DefaultContextCache implementation by using entrySet().removeIf() --- .../test/context/cache/DefaultContextCache.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java index 4deac3c8a99..b6d38af1818 100644 --- a/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java +++ b/spring-test/src/main/java/org/springframework/test/context/cache/DefaultContextCache.java @@ -341,11 +341,7 @@ public class DefaultContextCache implements ContextCache { } // Remove empty entries from the hierarchy map. - for (Map.Entry> entry : this.hierarchyMap.entrySet()) { - if (entry.getValue().isEmpty()) { - this.hierarchyMap.remove(entry.getKey()); - } - } + this.hierarchyMap.entrySet().removeIf(entry -> entry.getValue().isEmpty()); } private void remove(List removedContexts, MergedContextConfiguration key) {