Joerg Hoh created SLING-11612:
---------------------------------

             Summary: OSGIserviceInjector.getService() blocks under load
                 Key: SLING-11612
                 URL: https://issues.apache.org/jira/browse/SLING-11612
             Project: Sling
          Issue Type: Improvement
          Components: Sling Models
    Affects Versions: Models Implementation 1.5.2
            Reporter: Joerg Hoh



Under load the injection of OSGI references can block as the ServiceRegistry 
like this:

{noformat}
        at jdk.internal.misc.Unsafe.park([email protected]/Native Method)
        - parking to wait for  <0x00000007e65f69e8> (a 
java.util.concurrent.CountDownLatch$Sync)
        at 
java.util.concurrent.locks.LockSupport.park([email protected]/LockSupport.java:194)
        at 
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt([email protected]/AbstractQueuedSynchronizer.java:885)
        at 
java.util.concurrent.locks.AbstractQueuedSynchronizer.doAcquireSharedInterruptibly([email protected]/AbstractQueuedSynchronizer.java:1039)
        at 
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly([email protected]/AbstractQueuedSynchronizer.java:1345)
        at 
java.util.concurrent.CountDownLatch.await([email protected]/CountDownLatch.java:232)
        at 
org.apache.felix.framework.ServiceRegistry.getService(ServiceRegistry.java:380)
        at org.apache.felix.framework.Felix.getService(Felix.java:3984)
        at 
org.apache.felix.framework.Felix.getServiceReferences(Felix.java:3895)
        at 
org.apache.felix.framework.Felix.getAllowedServiceReferences(Felix.java:3947)
        at 
org.apache.felix.framework.BundleContextImpl.getServiceReferences(BundleContextImpl.java:414)
        at 
org.apache.sling.models.impl.injectors.OSGiServiceInjector.getService(OSGiServiceInjector.java:106)
        at 
org.apache.sling.models.impl.injectors.OSGiServiceInjector.getValue(OSGiServiceInjector.java:170)
        at 
org.apache.sling.models.impl.injectors.OSGiServiceInjector.getValue(OSGiServiceInjector.java:99)
        at 
org.apache.sling.models.impl.ModelAdapterFactory.injectElementInternal(ModelAdapterFactory.java:598)
        at 
org.apache.sling.models.impl.ModelAdapterFactory.injectElement(ModelAdapterFactory.java:532)
{noformat}

For this situation Sling Scripting uses a cache in the SlingScriptHelper, which 
prevents too frequent access to the registry. Such a method (and potentially 
even the same cache) should be used for the OsgiServiceInjector as well.






--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to