Skip to content

Commit

Permalink
[rest] Fix Java 21 build (#4171)
Browse files Browse the repository at this point in the history
Signed-off-by: Holger Friedrich <[email protected]>
  • Loading branch information
holgerfriedrich authored Apr 5, 2024
1 parent 3e16027 commit 875ebaa
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class ExpiringUserSecurityContextCache {
static final int CLEANUP_FREQUENCY = 10;

private final long keepPeriod;
private final Map<String, Entry> entryMap;
private final Map<String, MyEntry> entryMap;

private int calls = 0;

Expand All @@ -42,7 +42,7 @@ public ExpiringUserSecurityContextCache(long expirationTime) {
entryMap = new LinkedHashMap<>() {
private static final long serialVersionUID = -1220310861591070462L;

protected boolean removeEldestEntry(Map.@Nullable Entry<String, Entry> eldest) {
protected boolean removeEldestEntry(Map.@Nullable Entry<String, MyEntry> eldest) {
return size() > MAX_SIZE;
}
};
Expand All @@ -54,23 +54,23 @@ protected boolean removeEldestEntry(Map.@Nullable Entry<String, 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;
}
return null;
}

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;
Expand All @@ -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;
}
Expand Down

0 comments on commit 875ebaa

Please sign in to comment.