fix a race condtion in unget service from service factory.
@@ -501,12 +501,12 @@ public class ServiceRegistry
Object svc = holder != null ? holder.m_service : null;
if (svc != null)
+ {
+ if (usage.m_svcHolderRef.compareAndSet(holder, null))
{
// Check the count again to ensure that nobody else has just
// obtained the service again
if (usage.m_count.get() <= 0)
- {
- if (usage.m_svcHolderRef.compareAndSet(holder, null))
{
// Temporarily increase the usage again so that the
// service factory still sees the usage in the unget
@@ -521,7 +521,6 @@ public class ServiceRegistry
// now we can decrease the usage again
usage.m_count.decrementAndGet();
}
-
}
}
}
