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 18:09:00 UTC

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

     [ https://issues.apache.org/jira/browse/FELIX-6420?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Stefan Bischof resolved FELIX-6420.
-----------------------------------
    Resolution: Not A Problem

> 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.8, scr-2.1.26
>            Reporter: Stefan Bischof
>            Priority: Major
>
> 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)