This is an automated email from the ASF dual-hosted git repository.
pauls pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new 7378a7f FELIX-6331: fix a race condtion in unget service from service
factory.
7378a7f is described below
commit 7378a7f0f014b4dc75b437e30869298dc20d24a4
Author: Karl Pauls <[email protected]>
AuthorDate: Thu Sep 17 23:15:50 2020 +0200
FELIX-6331: fix a race condtion in unget service from service factory.
---
.../main/java/org/apache/felix/framework/ServiceRegistry.java | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git
a/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
b/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
index 68bab2c..34d49d5 100644
--- a/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
+++ b/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
@@ -502,11 +502,11 @@ public class ServiceRegistry
if (svc != 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))
{
- 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)
{
// 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();
}
-
}
}
}