[spotbugs] Don't use class from java.util.concurrent for locking

Use a dedicated Lock object to lock the scheduler in
RepositoryCache#configureEviction to fix spotbugs warning
JLM_JSR166_UTILCONCURRENT_MONITORENTER.

Change-Id: I003dcf0ed1a0a3f4eea5d8a2f51a07473d28a928
Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
This commit is contained in:
Matthias Sohn 2020-12-05 00:39:09 +01:00
parent 50f0347ea3
commit 13e0ffbd3d
1 changed files with 3 additions and 1 deletions

View File

@ -201,6 +201,8 @@ static void reconfigure(RepositoryCacheConfig repositoryCacheConfig) {
private volatile long expireAfter;
private Object schedulerLock = new Lock();
private RepositoryCache() {
cacheMap = new ConcurrentHashMap<>();
openLocks = new Lock[4];
@ -214,7 +216,7 @@ private void configureEviction(
RepositoryCacheConfig repositoryCacheConfig) {
expireAfter = repositoryCacheConfig.getExpireAfter();
ScheduledThreadPoolExecutor scheduler = WorkQueue.getExecutor();
synchronized (scheduler) {
synchronized (schedulerLock) {
if (cleanupTask != null) {
cleanupTask.cancel(false);
}