Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2014-08-19 13:17:38 -0400
committerThomas Watson2015-01-30 09:00:09 -0500
commit78f2aa9350271ac0f9fc46d87d864992c20fe42b (patch)
tree0f9d34fd8bb514b136b3f97ab42ee9cfdc6eb9a1
parentdbf82c083770b6f9d08dbdbdbd178715e9844966 (diff)
downloadrt.equinox.framework-78f2aa9350271ac0f9fc46d87d864992c20fe42b.tar.gz
rt.equinox.framework-78f2aa9350271ac0f9fc46d87d864992c20fe42b.tar.xz
rt.equinox.framework-78f2aa9350271ac0f9fc46d87d864992c20fe42b.zip
Bug 442091 - LockSet should ReentrantLock.isHeldByCurrentThread() instead of getHoldCount
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java18
1 files changed, 6 insertions, 12 deletions
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java
index 806e7fcca..2db897851 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/container/LockSet.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2012 IBM Corporation and others.
+ * Copyright (c) 2012, 2014 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -40,19 +40,13 @@ public class LockSet<T> {
locks.put(t, lock);
}
}
- boolean obtained = lock.tryLock(time, unit);
+ boolean obtained = !lock.isHeldByCurrentThread() && lock.tryLock(time, unit);
if (obtained) {
synchronized (monitor) {
- if (lock.getHoldCount() > 1) {
- // we don't allow reentrant locks
- lock.unlock();
- obtained = false;
- } else {
- // must check that another thread did not remove the lock
- // when unlocking while we were waiting to obtain the lock
- if (!locks.containsKey(t)) {
- locks.put(t, lock);
- }
+ // must check that another thread did not remove the lock
+ // when unlocking while we were waiting to obtain the lock
+ if (!locks.containsKey(t)) {
+ locks.put(t, lock);
}
}
}

Back to the top