From 13b77df65f6e3d4685135ce940f9050e2dbd6a8b Mon Sep 17 00:00:00 2001 From: Holger Friedrich Date: Fri, 5 Apr 2024 19:26:12 +0200 Subject: [PATCH] [rest] Fix Java 21 build Signed-off-by: Holger Friedrich --- .../ExpiringUserSecurityContextCache.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCache.java b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCache.java index 837468e724c..c400494c448 100644 --- a/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCache.java +++ b/bundles/org.openhab.core.io.rest.auth/src/main/java/org/openhab/core/io/rest/auth/internal/ExpiringUserSecurityContextCache.java @@ -33,7 +33,7 @@ public class ExpiringUserSecurityContextCache { static final int CLEANUP_FREQUENCY = 10; private final long keepPeriod; - private final Map entryMap; + private final Map entryMap; private int calls = 0; @@ -42,7 +42,7 @@ public ExpiringUserSecurityContextCache(long expirationTime) { entryMap = new LinkedHashMap<>() { private static final long serialVersionUID = -1220310861591070462L; - protected boolean removeEldestEntry(Map.@Nullable Entry eldest) { + protected boolean removeEldestEntry(Map.@Nullable Entry eldest) { return size() > MAX_SIZE; } }; @@ -54,7 +54,7 @@ protected boolean removeEldestEntry(Map.@Nullable Entry eldest) { new HashSet<>(entryMap.keySet()).forEach(k -> getEntry(k)); calls = 0; } - Entry entry = getEntry(key); + MyEntry entry = getEntry(key); if (entry != null) { return entry.value; } @@ -62,15 +62,15 @@ protected boolean removeEldestEntry(Map.@Nullable Entry eldest) { } public synchronized void put(String key, UserSecurityContext value) { - entryMap.put(key, new Entry(System.currentTimeMillis(), value)); + entryMap.put(key, new MyEntry(System.currentTimeMillis(), value)); } public synchronized void clear() { entryMap.clear(); } - private @Nullable Entry getEntry(String key) { - Entry entry = entryMap.get(key); + private @Nullable MyEntry getEntry(String key) { + MyEntry entry = entryMap.get(key); if (entry != null) { final long curTimeMillis = System.currentTimeMillis(); long entryAge = curTimeMillis - entry.timestamp; @@ -84,11 +84,11 @@ public synchronized void clear() { return entry; } - static class Entry { + static class MyEntry { public long timestamp; public final UserSecurityContext value; - Entry(long timestamp, UserSecurityContext value) { + MyEntry(long timestamp, UserSecurityContext value) { this.timestamp = timestamp; this.value = value; }