Fix locking issue
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1492736 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
index b08ecf6..fc6e08d 100644
--- a/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
+++ b/ipojo/runtime/core/src/main/java/org/apache/felix/ipojo/util/DependencyModel.java
@@ -579,8 +579,8 @@
* @return {@literal true} if the lock was acquired within the method, {@literal false} otherwise.
*/
public boolean acquireReadLockIfNotHeld() {
- if (! m_lock.isWriteLockedByCurrentThread()) {
- m_lock.writeLock().lock();
+ if (m_lock.getReadHoldCount() == 0) {
+ m_lock.readLock().lock();
return true;
}
return false;
@@ -591,8 +591,8 @@
* @return {@literal true} if the lock has no more holders, {@literal false} otherwise.
*/
public boolean releaseReadLockIfHeld() {
- if (m_lock.isWriteLockedByCurrentThread()) {
- m_lock.writeLock().unlock();
+ if (m_lock.getReadHoldCount() > 0) {
+ m_lock.readLock().unlock();
}
return m_lock.getWriteHoldCount() == 0;
}