Hi, Kris Pruden schrieb: > Hi, > > I'm puzzling through some strange behaviour in my application related to > what appears to be a race and/or some weird interaction between services > registered via SCR and bundles trying to monitor these services via the > ServiceTracker API. > > I don't have any good theories at the moment, so I was hoping if I > described what I'm seeing it might job somebody's memory... > > Here's my situation. I have an application made up of about a > half-dozen or so bundles, most (but not all) of which register their > services using DS/SCR. I'm using pax:exam to run automated functional > tests for this application. Unfortunately, my tests are not reliable - > they fail intermittently. When there's a failure, it's always because > of an NPE on one of the SCR-injected @Reference attributes of a > service/component. It's hard to tell for sure, but what looks like is > happening is this: > 1. The SCR starts and registers a component/service > 2. The functional test, which was waiting for that service to become > available, gets a reference to the service > 3. The SCR stops the service, then immediately starts and registers a > new instance of the service > > Unfortunately, at this point the test bundle now has a reference to the > "stopped" instance of the service, which has had all of its @Reference > fields set to null (hence the NPE). > > What I can't figure out is why this is happening. > > Anyone have any suggestions about where I should look next, or any known > SCR gotchas that I might be running into?
Well, from far outside, it must be said, that a service may come and go at any time for any reason... Now, this doesn't help you, of course. But without a more in-depth look into the situation I cannot tell much, other than: It should work actually. Let me quickly recapitulate: Your component under test is a SCR component which also is registered as a service: Is this a delayed service component or a service factory component ? SCR stops and immediately restarts the service: Are you updating configuration admin configuration supplied to the component during the test ? You talk about a @Reference annotation: Does this mean the SCR component under test has a reference to another service ? Is this reference mandatory or optional ? Is it static or dynamic ? Is there a change in the referenced service during the test ? Last but not least: What DS implementation are you using ? Or: what version of Felix SCR are you using ? Regards Felix --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]

