Skip to content
Permalink
Browse files
Merge pull request #56 from csamak/obtain-lock
Call Lock.lock before the try
  • Loading branch information
henrib committed Jun 4, 2021
2 parents 3bbdc91 + c45b357 commit b54b3c9a912a3d96e584655f1ffd9564f28942ca
Showing 1 changed file with 3 additions and 3 deletions.
@@ -300,15 +300,15 @@ public Constructor<?> getConstructor(final Class<?> c, final MethodKey key) {
*/
private ClassMap getMap(final Class<?> c) {
ClassMap classMap;
lock.readLock().lock();
try {
lock.readLock().lock();
classMap = classMethodMaps.get(c);
} finally {
lock.readLock().unlock();
}
if (classMap == null) {
lock.writeLock().lock();
try {
lock.writeLock().lock();
// try again
classMap = classMethodMaps.get(c);
if (classMap == null) {
@@ -334,8 +334,8 @@ public void setLoader(ClassLoader cloader) {
cloader = getClass().getClassLoader();
}
if (!cloader.equals(loader)) {
lock.writeLock().lock();
try {
lock.writeLock().lock();
// clean up constructor and class maps
final Iterator<Map.Entry<MethodKey, Constructor<?>>> mentries = constructorsMap.entrySet().iterator();
while (mentries.hasNext()) {

0 comments on commit b54b3c9

Please sign in to comment.