You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Stefan Bischof (Jira)" <ji...@apache.org> on 2021/06/01 16:28:00 UTC

[jira] [Created] (FELIX-6420) Injection of unbound optional References in Constructor:

Stefan Bischof created FELIX-6420:
-------------------------------------

             Summary: Injection of unbound optional References in Constructor:
                 Key: FELIX-6420
                 URL: https://issues.apache.org/jira/browse/FELIX-6420
             Project: Felix
          Issue Type: Bug
          Components: Declarative Services (SCR)
    Affects Versions: scr-2.1.26, scr-2.1.8
            Reporter: Stefan Bischof


OSGi-Spec:
{code:java}
If the constructor parameter is associated with a reference having cardinality of 0..1 and there is no bound service for the reference, then the value null will be supplied as the constructor parameter. 
{code}
 

{{}}

{{when trying with Felix-SCR i got this Exception:}}
{{}}
{code:java}
java.lang.InstantiationException: Unable to get service for reference optionalNull
	at org.apache.felix.scr.impl.inject.internal.ComponentConstructorImpl.newInstance(ComponentConstructorImpl.java:301)
	at org.apache.felix.scr.impl.manager.SingleComponentManager.createImplementationObject(SingleComponentManager.java:279)
	at org.apache.felix.scr.impl.manager.SingleComponentManager.createComponent(SingleComponentManager.java:115)
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:984)
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getServiceInternal(SingleComponentManager.java:957)
	at org.apache.felix.scr.impl.manager.SingleComponentManager.getService(SingleComponentManager.java:902)
	at o

{code}

{{You can test it with this test in the PR to the ds-tck:}}

[https://github.com/osgi/osgi/pull/230
]{{}}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)