[ 
https://issues.apache.org/jira/browse/FELIX-3824?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13532405#comment-13532405
 ] 

Guillaume Nodet commented on FELIX-3824:
----------------------------------------

Proposed patch for the ServiceRegistry#unregisterServices method:
{code}
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 f8dea41..f280b4e 100644
--- a/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
+++ b/framework/src/main/java/org/apache/felix/framework/ServiceRegistry.java
@@ -202,7 +202,14 @@ public class ServiceRegistry
         {
             if (((ServiceRegistrationImpl) regs[i]).isValid())
             {
-                regs[i].unregister();
+                try
+                {
+                    regs[i].unregister();
+                }
+                catch (IllegalStateException e)
+                {
+                    // Ignore exception if the service has already been 
unregistered
+                }
             }
         }
 {code}
                
> Possible InvalidStateException thrown while unregistering bundle services
> -------------------------------------------------------------------------
>
>                 Key: FELIX-3824
>                 URL: https://issues.apache.org/jira/browse/FELIX-3824
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>            Reporter: Guillaume Nodet
>            Assignee: Guillaume Nodet
>            Priority: Minor
>
> I think there's a small possibility that an InvalidStateException is thrown 
> when unregistering services after the bundle is stopped.  It can only happen 
> if the registration is held by someone and unregistered concurrently with the 
> bundle being stopped.
> I think it does not hurt to catch and ignore it as I had it once.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to