Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[rest] Fix Java 21 build #4171

Merged
merged 1 commit into from
Apr 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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