Skip to content
Closed
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 @@ -80,7 +80,16 @@ public class CacheManager extends ConfigTestElement implements TestStateListener
public static final String MAX_SIZE = "maxSize"; // $NON-NLS-1$
//-

private transient InheritableThreadLocal<Cache<String, CacheEntry>> threadCache;
@SuppressWarnings("ThreadLocalUsage") // intentionally using InheritableThreadLocal for per-thread cache
private final transient InheritableThreadLocal<Cache<String, CacheEntry>> threadCache =
new InheritableThreadLocal<Cache<String, CacheEntry>>(){
@Override
protected Cache<String, CacheEntry> initialValue() {
return Caffeine.newBuilder()
.maximumSize(getMaxSize())
.build();
}
};

private transient boolean useExpires; // Cached value

Expand Down Expand Up @@ -602,15 +611,7 @@ public void clear(){

private void clearCache() {
log.debug("Clear cache");
// TODO: avoid re-creating the thread local every time, reset its contents instead
threadCache = new InheritableThreadLocal<Cache<String, CacheEntry>>(){
@Override
protected Cache<String, CacheEntry> initialValue() {
return Caffeine.newBuilder()
.maximumSize(getMaxSize())
.build();
}
};
threadCache.remove();
}

/**
Expand Down