]> source.dussan.org Git - jgit.git/commitdiff
[spotbugs] Don't use class from java.util.concurrent for locking 27/173427/6
authorMatthias Sohn <matthias.sohn@sap.com>
Fri, 4 Dec 2020 23:39:09 +0000 (00:39 +0100)
committerMatthias Sohn <matthias.sohn@sap.com>
Tue, 22 Dec 2020 09:53:01 +0000 (10:53 +0100)
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>
org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java

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