diff options
author | Matthias Sohn <matthias.sohn@sap.com> | 2020-12-05 00:39:09 +0100 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2020-12-22 10:53:01 +0100 |
commit | 13e0ffbd3d87fba58e0739056810c51cb3e93b9b (patch) | |
tree | b1fbaaf84465b8cfd20a216da28cf141a4cbd576 | |
parent | 50f0347ea3a17aa754dfb139acfc2d57ea488fa4 (diff) | |
download | jgit-13e0ffbd3d87fba58e0739056810c51cb3e93b9b.tar.gz jgit-13e0ffbd3d87fba58e0739056810c51cb3e93b9b.zip |
[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>
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java index d36ccd5bea..2c108de86f 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RepositoryCache.java @@ -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); } |