You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by tj...@apache.org on 2020/03/17 21:24:41 UTC
[felix-dev] branch master updated: FELIX-6241 - Ignore
IllegalStateException on ungetService
This is an automated email from the ASF dual-hosted git repository.
tjwatson 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 bfd6bab FELIX-6241 - Ignore IllegalStateException on ungetService
bfd6bab is described below
commit bfd6bab14a72e15678d7af7c64f3ee242995d081
Author: Thomas Watson <tj...@us.ibm.com>
AuthorDate: Tue Mar 17 16:11:15 2020 -0500
FELIX-6241 - Ignore IllegalStateException on ungetService
---
.../org/apache/felix/scr/impl/manager/SingleRefPair.java | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleRefPair.java b/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleRefPair.java
index a7592bc..59eb7c3 100644
--- a/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleRefPair.java
+++ b/scr/src/main/java/org/apache/felix/scr/impl/manager/SingleRefPair.java
@@ -71,7 +71,7 @@ public class SingleRefPair<S, T> extends RefPair<S, T>
{
if (bundleContext != null)
{
- bundleContext.ungetService(getRef());
+ safeUngetService(bundleContext, getRef());
}
}
}
@@ -97,8 +97,20 @@ public class SingleRefPair<S, T> extends RefPair<S, T>
if (!setServiceObject(key, service))
{
// Another thread got the service before, so unget our
- context.ungetService( getRef() );
+ safeUngetService(context, getRef());
}
return true;
}
+
+ static private void safeUngetService(BundleContext context, ServiceReference<?> ref)
+ {
+ try
+ {
+ context.ungetService(ref);
+ }
+ catch (IllegalStateException e)
+ {
+ // ignore
+ }
+ }
}