Dirk Rudolph created SLING-10616:
------------------------------------

             Summary: Respect Target filter for optional/static/greedy 
reference updates
                 Key: SLING-10616
                 URL: https://issues.apache.org/jira/browse/SLING-10616
             Project: Sling
          Issue Type: Bug
          Components: Testing
    Affects Versions: Testing OSGi Mock 3.1.2
            Reporter: Dirk Rudolph
             Fix For: Testing OSGi Mock 3.1.4


The MockBundleContext respects the Reference target for dynamic references

[https://github.com/apache/sling-org-apache-sling-testing-osgi-mock/blob/master/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java#L156]

but it does not for static+greedy ones

[https://github.com/apache/sling-org-apache-sling-testing-osgi-mock/blob/master/core/src/main/java/org/apache/sling/testing/mock/osgi/MockBundleContext.java#L177]

Consider having a ServiceInterfaceA with a DefaultImplementation and a 
CustomImplementation. When the CustomImplementation references the 
DefaultImplementation optional+static+greedy with for example a target filter 
on the objectClass property this will cause a StackOverflowError when 
registering the services.
{code:java}
interface ServiceInterfaceA {}

class DefaultImplementation implements ServiceInterfaceA {}

class CustomImplementation implements ServiceInterfaceA {
  @Reference(
    cardinality=OPTIONAL, 
    policy=STATIC, 
    policyOption = GREEDY, 
    target="(objectClass=*DefaultImplementation)")
  private ServiceInterfaceA defaultImplementation;
}
 {code}
 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to