You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Pierre De Rop (JIRA)" <ji...@apache.org> on 2018/10/08 19:55:00 UTC

[jira] [Commented] (FELIX-5956) NPE when invoking a lifecycle runnable method from init method

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

Pierre De Rop commented on FELIX-5956:
--------------------------------------

Added test case for this issue in revision 1843192:

Adding         org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/components/FELIX5956.java
Adding         org.apache.felix.dependencymanager.runtime.itest/src/org/apache/felix/dm/runtime/itest/tests/FELIX5956Test.java



> NPE when invoking a lifecycle runnable method from init method
> --------------------------------------------------------------
>
>                 Key: FELIX-5956
>                 URL: https://issues.apache.org/jira/browse/FELIX-5956
>             Project: Felix
>          Issue Type: Bug
>          Components: Dependency Manager Runtime
>    Affects Versions: org.apache.felix.dependencymanager-r1
>            Reporter: Pierre De Rop
>            Assignee: Pierre De Rop
>            Priority: Major
>             Fix For: org.apache.felix.dependencymanager-r12
>
>
> When you use a DM lifecycle controller in order to trigger component activation from the @Init method, a NPE is throw if you invoke the lifecylce runnable from the init method.
> For example, the following code:
> {code:java}
> @Component
> public class MyServiceImpl implements MyService {
>     @LifecycleController
>     volatile Runnable _start;
>     @Init
>     void init() {
>         _start.run(); // immediately trigger service activation
>     }
> }
> {code}
> produces the following NPE:
> {code}
> Caused by: java.lang.NullPointerException
> 	at org.apache.felix.dm.runtime.ToggleServiceDependency.activate(ToggleServiceDependency.java:49)
> 	at org.apache.felix.dm.runtime.ServiceLifecycleHandler$ComponentStarter.run(ServiceLifecycleHandler.java:431)
> 	at org.apache.felix.dependencymanager.samples.hello.annot.ServiceProviderImpl.init(ServiceProviderImpl.java:47)
> 	... 65 more
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)