Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [equinox-dev] ProSyst Declarative Services: Multiple calls to activate() for single service instance

Jan,

I think the bug I referenced in my earlier reply
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=186280) is related to
what you're seeing.  If you read the description, it mentions a
deadlock (which may or may not be related), but also mentions the
dual-activation problem:

"Another issue we've been seeing which I believe is related is one instance of a
component being activated twice. I have been able to reproduce this issue with
a simple set of bundles. The dual activation issue arises when an immediate
component is tracked by a ServiceTracker (or anything that will attempt to
immediately get a reference to its service Object). As soon as DS registers the
component's lazy-initializing ServiceFactory, the ServiceTracker requests it,
causing the component to be built and activated.  If the timing is right, DS
also activates the component due to it being immediate. I've got stack traces
from both activate() calls in this scenario."

Stoyan attached a patch for this issue to the report which may fix your problem.

-Jeremy

On 8/7/07, Jan Stette <jan.stette@xxxxxxxxx> wrote:
> I originally posted this issue to the osgi-dev list as I wasn't sure if the
> seen behavior was allowed by the spec or not.  The comments there suggest
> that this looks like a bug, so I'm posting this here.  This problem is seen
> using the ProSyst declarative services implementation as originally
> contributed to Eclipse.
>
> What we're seeing is basically this sequence of events:
> - A service (X) is "immediate" so is registered on startup, and activated.
> - Some time (much) later, a service (Y) declared in another bundle tries to
> locate service X through the ComponentContext.locateService() method.
> - This service is looked up OK so the right instance is found, but
> activate() is called on the service instance again.
>
> Stepping through the Declarative Services code it seems to indeed find the
> existing service within the corresponding ServiceFactory as registered by
> the DS bundle ( i.e. the "proxy" service).  However, after finding the
> existing service, it still calls activate() on it.  The specific code
> fragment looks like:
>
> <...look up the component instance, in this case finding it... so the if()
> statement below tests as false. >
>
>         if (componentInstance == null) {
>             componentInstance = new ComponentInstanceImpl(instance, this);
>             componentInstance.setComponentContext(new
> ComponentContextImpl(
>                      this, usingBundle, componentInstance, mgr));
>         }
>
>         bind(componentInstance);
>         activate(usingBundle, componentInstance);
>
> <return the component instance>
>
> To me, it seems like activate() (and maybe bind) should have been called
> inside the 'if' statement, i.e. only when creating a new instance?  That's
> just a guess based on my first look at the code though!
>
> Note that we only see this issue when the service is accessed the second
> time from outside its own bundle.  From looking at the framework code, I
> suspect this is because service objects are cached for each bundle?  In any
> case, this is something to bear in mind if trying to reproduce this.
>
> Regards,
> Jan
>
>
>
> _______________________________________________
> equinox-dev mailing list
> equinox-dev@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/equinox-dev
>
>


Back to the top