[
https://issues.apache.org/jira/browse/FELIX-5056?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14907872#comment-14907872
]
German Vega commented on FELIX-5056:
------------------------------------
After debugging the DependencyHandler, it seems that the problem is caused
because the org.apache.felix.ipojo.handlers.dependency.Dependency object
representing the requirement is not registered as an interceptor of the inner
class methods.
Because of this, the Dependency object is not invoked onEntry and onFinally of
the inner class methods, and the dependency Usage counts are not correct. The
stack counter of the Usage is never decremented to zero, and so it always the
reference to the first bound target.
The attached proposed patch seems to correct the problem in my case, but I have
not run the iPOJO regression tests to verify it.
> Error in service dependency field injection, when accessed from an inner class
> ------------------------------------------------------------------------------
>
> Key: FELIX-5056
> URL: https://issues.apache.org/jira/browse/FELIX-5056
> Project: Felix
> Issue Type: Bug
> Components: iPOJO
> Affects Versions: ipojo-runtime-1.12.1
> Reporter: German Vega
>
> A component defines a simple mandatroy dependency, with an injected field.
> When the field is accessed in one of the methods of an inner class of the
> component, it is not always updated when the target of the dependency
> changes.
> The error doesn't happen all the time, work well for some dependencies. For a
> given dependency, sometimes it seems to work depending on the invoking
> thread.
> WORKAROUND : define a private method in the component to acces the field, and
> invoke this method from the inner class (instead of accessing the field
> directly)
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)