From 14c5103538be949e6cfce77d8be0170599006429 Mon Sep 17 00:00:00 2001 From: "Sean C. Sullivan" Date: Sun, 22 Jan 2023 14:53:21 -0800 Subject: [PATCH] avoid array allocation in ResponseCacheImpl --- .../java/com/netflix/eureka/registry/ResponseCacheImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/eureka-core/src/main/java/com/netflix/eureka/registry/ResponseCacheImpl.java b/eureka-core/src/main/java/com/netflix/eureka/registry/ResponseCacheImpl.java index 3d498e4bd..863e6bea4 100644 --- a/eureka-core/src/main/java/com/netflix/eureka/registry/ResponseCacheImpl.java +++ b/eureka-core/src/main/java/com/netflix/eureka/registry/ResponseCacheImpl.java @@ -74,6 +74,8 @@ * @author Karthik Ranganathan, Greg Kim */ public class ResponseCacheImpl implements ResponseCache { + private static final Key.KeyType[] KEY_TYPE_VALUES = Key.KeyType.values(); + private static final Version[] VERSION_VALUES = Version.values(); private static final Logger logger = LoggerFactory.getLogger(ResponseCacheImpl.class); @@ -249,8 +251,8 @@ public void stop() { */ @Override public void invalidate(String appName, @Nullable String vipAddress, @Nullable String secureVipAddress) { - for (Key.KeyType type : Key.KeyType.values()) { - for (Version v : Version.values()) { + for (Key.KeyType type : KEY_TYPE_VALUES) { + for (Version v : VERSION_VALUES) { invalidate( new Key(Key.EntityType.Application, appName, type, v, EurekaAccept.full), new Key(Key.EntityType.Application, appName, type, v, EurekaAccept.compact),