Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-11030

OSGiServiceInjector.getService() calls ungetService even if service is not get

    XMLWordPrintableJSON

Details

    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

      Attachments

        Activity

          People

            cziegeler Carsten Ziegeler
            cziegeler Carsten Ziegeler
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: