Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2014-08-19 17:17:38 +0000
committerThomas Watson2014-08-19 17:17:38 +0000
commite667cadd191f5771363910ff98533123372f3a28 (patch)
treed02ba693bd2fc56b75b4deb60c3c5aa0db8e72bd /bundles/org.eclipse.osgi
parentb203efe8f485ce36de5e87d8c0d0c7fae094de92 (diff)
downloadrt.equinox.framework-e667cadd191f5771363910ff98533123372f3a28.tar.gz
rt.equinox.framework-e667cadd191f5771363910ff98533123372f3a28.tar.xz
rt.equinox.framework-e667cadd191f5771363910ff98533123372f3a28.zip
Bug 442091 - LockSet should ReentrantLock.isHeldByCurrentThread() instead of getHoldCount
Diffstat (limited to 'bundles/org.eclipse.osgi')
-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