[jira] [Commented] (FELIX-5198) Service should not be available while being unregistered
[ https://issues.apache.org/jira/browse/FELIX-5198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15167396#comment-15167396 ] Richard S. Hall commented on FELIX-5198: Of course it will trigger it. The issue was people wanted one last chance to talk to the service before it was gone. My position at the time was, "What's the point, the service probably isn't working anyway." Their position was, "Well, for my components I know they are working." It is legitimate that there is no chance to say goodbye unless we allow retrieval, but whether or not this is useful is totally dependent on the service implementation. I can pretty much guarantee that you will cause some people pain if you do this, but I'm not against it. > Service should not be available while being unregistered > > > Key: FELIX-5198 > URL: https://issues.apache.org/jira/browse/FELIX-5198 > Project: Felix > Issue Type: Bug > Components: Framework >Affects Versions: framework-5.4.0 >Reporter: Carsten Ziegeler >Assignee: David Bosschaert > Fix For: framework-5.6.0 > > Attachments: felix-5198.patch > > > Currently it is possible to get a service while it is being unregistered - > if the service is get during processing of the unregistering event. This is > the order of events: > a) a service (factory) is unregistered in the framework > b) the UNREGISTERING event is sent before the service is actually > unregistered (this is as defined in the spec) > c) the above event is handled synchronously, reactivating dependent components > d) during this reactivation, some component looks up the service that is > unregistered in a). as this service is still registered and marked as valid, > it gets it > According to ServiceRegistration.unregister the service should not be > available anymore while the events are sent -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (FELIX-5198) Service should not be available while being unregistered
[ https://issues.apache.org/jira/browse/FELIX-5198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15167251#comment-15167251 ] Richard S. Hall commented on FELIX-5198: I won't say I remember all of the specifics, but there are issues around this. I think at one time we did implement it so that a service became unavailable as soon as unregistering started, but we received a lot of blow back from people who wanted to do something with the service to say goodbye. The compromise we came up with was [I think] to only allow people who already had services references to be able to get a service, but to now allow any new lookups once unregistration started. > Service should not be available while being unregistered > > > Key: FELIX-5198 > URL: https://issues.apache.org/jira/browse/FELIX-5198 > Project: Felix > Issue Type: Bug > Components: Framework >Affects Versions: framework-5.4.0 >Reporter: Carsten Ziegeler >Assignee: David Bosschaert > Fix For: framework-5.6.0 > > > Currently it is possible to get a service while it is being unregistered - > if the service is get during processing of the unregistering event. This is > the order of events: > a) a service (factory) is unregistered in the framework > b) the UNREGISTERING event is sent before the service is actually > unregistered (this is as defined in the spec) > c) the above event is handled synchronously, reactivating dependent components > d) during this reactivation, some component looks up the service that is > unregistered in a). as this service is still registered and marked as valid, > it gets it > According to ServiceRegistration.unregister the service should not be > available anymore while the events are sent -- This message was sent by Atlassian JIRA (v6.3.4#6332)
[jira] [Commented] (FELIX-5198) Service should not be available while being unregistered
[ https://issues.apache.org/jira/browse/FELIX-5198?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15166938#comment-15166938 ] Carsten Ziegeler commented on FELIX-5198: - Test case which currently fails: Index: src/test/java/org/apache/felix/framework/ServiceRegistryTest.java === --- src/test/java/org/apache/felix/framework/ServiceRegistryTest.java (Revision 1732253) +++ src/test/java/org/apache/felix/framework/ServiceRegistryTest.java (Arbeitskopie) @@ -23,6 +23,7 @@ import java.util.Arrays; import java.util.Collection; import java.util.Collections; +import java.util.Dictionary; import java.util.Hashtable; import java.util.List; import java.util.Observable; @@ -31,11 +32,11 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicInteger; +import java.util.concurrent.atomic.AtomicReference; -import junit.framework.TestCase; - import org.apache.felix.framework.ServiceRegistrationImpl.ServiceReferenceImpl; import org.apache.felix.framework.ServiceRegistry.ServiceHolder; +import org.apache.felix.framework.ServiceRegistry.ServiceRegistryCallbacks; import org.apache.felix.framework.ServiceRegistry.UsageCount; import org.easymock.MockControl; import org.mockito.AdditionalAnswers; @@ -54,6 +55,8 @@ import org.osgi.framework.hooks.service.FindHook; import org.osgi.framework.hooks.service.ListenerHook; +import junit.framework.TestCase; + public class ServiceRegistryTest extends TestCase { public void testRegisterEventHookService() @@ -1228,6 +1231,34 @@ sb.append("Obtained service"); } +public void testGettingServiceWhileUnregistering() throws Exception +{ +final Bundle regBundle = Mockito.mock(Bundle.class); + +final AtomicReference registryRef = new AtomicReference(); +final AtomicReference referenceRef = new AtomicReference(); +final ServiceRegistryCallbacks callback = new ServiceRegistryCallbacks() +{ + +@Override +public void serviceChanged(ServiceEvent event, Dictionary oldProps) +{ +if ( event.getType() == ServiceEvent.UNREGISTERING ) { +final Object obj = registryRef.get().getService(regBundle, referenceRef.get(), false); +assertNull(obj); +} +} + +}; +ServiceRegistry sr = new ServiceRegistry(null, callback); +registryRef.set(sr); + +ServiceRegistration reg1 = sr.registerService( +regBundle, new String [] {String.class.getName()}, "service is unregistering", null); +referenceRef.set(reg1.getReference()); +sr.unregisterService(regBundle, reg1); +} + private Object getPrivateField(Object obj, String fieldName) throws NoSuchFieldException, IllegalAccessException { > Service should not be available while being unregistered > > > Key: FELIX-5198 > URL: https://issues.apache.org/jira/browse/FELIX-5198 > Project: Felix > Issue Type: Bug > Components: Framework >Affects Versions: framework-5.4.0 >Reporter: Carsten Ziegeler >Assignee: David Bosschaert > Fix For: framework-5.6.0 > > > Currently it is possible to get a service while it is being unregistered - > if the service is get during processing of the unregistering event. This is > the order of events: > a) a service (factory) is unregistered in the framework > b) the UNREGISTERING event is sent before the service is actually > unregistered (this is as defined in the spec) > c) the above event is handled synchronously, reactivating dependent components > d) during this reactivation, some component looks up the service that is > unregistered in a). as this service is still registered and marked as valid, > it gets it > According to ServiceRegistration.unregister the service should not be > available anymore while the events are sent -- This message was sent by Atlassian JIRA (v6.3.4#6332)