Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
Models Implementation 1.5.0
-
None
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