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

Carsten Ziegeler updated SLING-11030:
-------------------------------------
    Description: 
The getService method gets all service references, but only from one of them it 
gets the service. However all service references are passed in to the callback 
for disposal. So for all references an unget is called, although it happened 
only for one

In addition, the code is assuming that the service with the highest ranking is 
always gettable. A null check is missing at : 
https://github.com/apache/sling-org-apache-sling-models-impl/blob/89fcb8702e29ad3322ee2a023ae6b24e5d2f83ab/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java#L114
 
It would be better to loop over the services references until one returns non 
null and then only dispose that reference later

  was:The getService method gets all service references, but only from one of 
them it gets the service. However all service references are passed in to the 
callback for disposal. So for all references an unget is called, although it 
happened only for one


> OSGiServiceInjector.getService() calls ungetService even if service is not get
> ------------------------------------------------------------------------------
>
>                 Key: SLING-11030
>                 URL: https://issues.apache.org/jira/browse/SLING-11030
>             Project: Sling
>          Issue Type: Bug
>          Components: Sling Models
>    Affects Versions: Models Implementation 1.5.0
>            Reporter: Carsten Ziegeler
>            Priority: Major
>             Fix For: Models Implementation 1.5.2
>
>
> The getService method gets all service references, but only from one of them 
> it gets the service. However all service references are passed in to the 
> callback for disposal. So for all references an unget is called, although it 
> happened only for one
> In addition, the code is assuming that the service with the highest ranking 
> is always gettable. A null check is missing at : 
> https://github.com/apache/sling-org-apache-sling-models-impl/blob/89fcb8702e29ad3322ee2a023ae6b24e5d2f83ab/src/main/java/org/apache/sling/models/impl/injectors/OSGiServiceInjector.java#L114
>  
> It would be better to loop over the services references until one returns non 
> null and then only dispose that reference later



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to