From d1fbae8397da00614a641e473ea9f580924fe1fa Mon Sep 17 00:00:00 2001 From: Stefan Winkler Date: Fri, 21 Apr 2023 13:08:00 +0200 Subject: [PATCH] Fix concurrency issue in Equinox Caching https://github.com/eclipse-equinox/equinox/issues/233 Fix bug in original PR Signed-off-by: Stefan Winkler --- .../weaving/internal/caching/ClassnameLockManager.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/ClassnameLockManager.java b/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/ClassnameLockManager.java index 3b0ace86f28..432b8118323 100644 --- a/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/ClassnameLockManager.java +++ b/bundles/org.eclipse.equinox.weaving.caching/src/org/eclipse/equinox/weaving/internal/caching/ClassnameLockManager.java @@ -119,6 +119,11 @@ private Lock acquireLock(final String classname, final boolean writeLock) { return resultingEntry; }); + // now activate the lock - this must happen outside of the compute() because + // otherwise we would end up in a deadlock with the classnameLocks + // ConcurrentHashMap lock in releaseLock() + lockWrapper[0].lock(); + // return the acquired lock return lockWrapper[0]; }