Author: rickhall
Date: Thu Apr 21 14:02:16 2011
New Revision: 1095714
URL: http://svn.apache.org/viewvc?rev=1095714&view=rev
Log:
Do not acquire bundle lock for removing a listner. (FELIX-2924)
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java
felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java
URL:
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java?rev=1095714&r1=1095713&r2=1095714&view=diff
==============================================================================
---
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java
(original)
+++
felix/trunk/framework/src/main/java/org/apache/felix/framework/BundleContextImpl.java
Thu Apr 21 14:02:16 2011
@@ -203,9 +203,10 @@ class BundleContextImpl implements Felix
{
checkValidity();
- // CONCURRENCY NOTE: This is a NOT a check-then-act situation,
- // because internally the framework acquires the bundle state
- // lock to ensure state consistency.
+ // CONCURRENCY NOTE: This is a check-then-act situation,
+ // but we ignore it since the time window is small and
+ // the result is the same as if the calling thread had
+ // won the race condition.
Object sm = System.getSecurityManager();
@@ -249,9 +250,10 @@ class BundleContextImpl implements Felix
{
checkValidity();
- // CONCURRENCY NOTE: This is a NOT a check-then-act situation,
- // because internally the framework acquires the bundle state
- // lock to ensure state consistency.
+ // CONCURRENCY NOTE: This is a check-then-act situation,
+ // but we ignore it since the time window is small and
+ // the result is the same as if the calling thread had
+ // won the race condition.
m_felix.removeServiceListener(m_bundle, l);
}
@@ -271,9 +273,10 @@ class BundleContextImpl implements Felix
{
checkValidity();
- // CONCURRENCY NOTE: This is a NOT a check-then-act situation,
- // because internally the framework acquires the bundle state
- // lock to ensure state consistency.
+ // CONCURRENCY NOTE: This is a check-then-act situation,
+ // but we ignore it since the time window is small and
+ // the result is the same as if the calling thread had
+ // won the race condition.
m_felix.removeFrameworkListener(m_bundle, l);
}
Modified:
felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
URL:
http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java?rev=1095714&r1=1095713&r2=1095714&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/Felix.java
Thu Apr 21 14:02:16 2011
@@ -2747,25 +2747,7 @@ public class Felix extends BundleImpl im
void removeBundleListener(BundleImpl bundle, BundleListener l)
{
- // Acquire bundle lock.
- try
- {
- acquireBundleLock(bundle, Bundle.STOPPING | Bundle.ACTIVE);
- }
- catch (IllegalStateException ex)
- {
- throw new IllegalStateException(
- "Can only remove listeners while bundle is active or
activating.");
- }
-
- try
- {
- m_dispatcher.removeListener(bundle, BundleListener.class, l);
- }
- finally
- {
- releaseBundleLock(bundle);
- }
+ m_dispatcher.removeListener(bundle, BundleListener.class, l);
}
/**
@@ -2844,28 +2826,8 @@ public class Felix extends BundleImpl im
**/
void removeServiceListener(BundleImpl bundle, ServiceListener l)
{
- // Acquire bundle lock.
- try
- {
- acquireBundleLock(bundle, Bundle.STOPPING | Bundle.ACTIVE);
- }
- catch (IllegalStateException ex)
- {
- throw new IllegalStateException(
- "Can only remove listeners while bundle is active or
activating.");
- }
-
- ListenerHook.ListenerInfo listener;
-
- try
- {
- listener =
- m_dispatcher.removeListener(bundle, ServiceListener.class, l);
- }
- finally
- {
- releaseBundleLock(bundle);
- }
+ ListenerHook.ListenerInfo listener =
+ m_dispatcher.removeListener(bundle, ServiceListener.class, l);
if (listener != null)
{
@@ -2905,25 +2867,7 @@ public class Felix extends BundleImpl im
void removeFrameworkListener(BundleImpl bundle, FrameworkListener l)
{
- // Acquire bundle lock.
- try
- {
- acquireBundleLock(bundle, Bundle.STOPPING | Bundle.ACTIVE);
- }
- catch (IllegalStateException ex)
- {
- throw new IllegalStateException(
- "Can only remove listeners while bundle is active or
activating.");
- }
-
- try
- {
- m_dispatcher.removeListener(bundle, FrameworkListener.class, l);
- }
- finally
- {
- releaseBundleLock(bundle);
- }
+ m_dispatcher.removeListener(bundle, FrameworkListener.class, l);
}
/**