You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Stefan Seifert (JIRA)" <ji...@apache.org> on 2015/06/01 22:56:18 UTC

[jira] [Commented] (SLING-4756) ServiceListener notifications are not filtered

    [ https://issues.apache.org/jira/browse/SLING-4756?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14567981#comment-14567981 ] 

Stefan Seifert commented on SLING-4756:
---------------------------------------

Completed: At revision: 1683002  

i replaced you partial filter implementation with FilterImpl from felix framework - it seems to work very well, and has no futher dependencies!

after applying FilterImpl i had to remove one of your unit tests
{code:java}
    public void testNestedObjectClassFilterMatches() throws InvalidSyntaxException {
        // this matches what the ServiceTracker creates
        Filter filter = bundleContext.createFilter("((" + Constants.OBJECTCLASS + "=" + Integer.class.getName() + "))");
...
{code}

because FelixImpl then throws an error:
{noformat}
org.osgi.framework.InvalidSyntaxException: Only one top-level operation allowed: ((objectClass=java.lang.Integer))
	at org.apache.felix.framework.FilterImpl.<init>(FilterImpl.java:51)
...
{noformat}

i assume FilterImpl is correct here.

> ServiceListener notifications are not filtered
> ----------------------------------------------
>
>                 Key: SLING-4756
>                 URL: https://issues.apache.org/jira/browse/SLING-4756
>             Project: Sling
>          Issue Type: Bug
>          Components: Testing
>    Affects Versions: Testing OSGi Mock 1.3.0
>            Reporter: Robert Munteanu
>            Assignee: Robert Munteanu
>             Fix For: Testing OSGi Mock 1.4.0
>
>
> While working on SLING-4605 I noticed many ClassCastExceptions filling the logs ( see below ). Similar exceptions are also present for the mock-jackrabbit module, only less verbose ( not stack traces )
> {noformat}
> 5432 [oak-executor-1] WARN org.apache.jackrabbit.oak.jcr.observation.ChangeProcessor - Error while dispatching observation events for ///*[11111b]@org.apache.sling.jcr.resource.internal.JcrResourceListener
> java.lang.ClassCastException: org.apache.sling.jcr.resource.internal.helper.jcr.JcrResourceProvider cannot be cast to org.osgi.service.event.EventAdmin
>         at org.apache.sling.jcr.resource.internal.JcrResourceListener.onEvent(JcrResourceListener.java:173)
>         at org.apache.jackrabbit.commons.observation.ListenerTracker$1.onEvent(ListenerTracker.java:164)
>         at org.apache.jackrabbit.oak.jcr.observation.ChangeProcessor.contentChanged(ChangeProcessor.java:302)
>         at org.apache.jackrabbit.oak.spi.commit.BackgroundObserver$1$1.call(BackgroundObserver.java:125)
>         at org.apache.jackrabbit.oak.spi.commit.BackgroundObserver$1$1.call(BackgroundObserver.java:119)
>         at java.util.concurrent.FutureTask.run(FutureTask.java:266)
>         at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
>         at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
>         at java.lang.Thread.run(Thread.java:745){noformat}
> The root cause is that when registering a {{ServiceTracker}} for a given class name the service tracker receives all registered services after it has been instantiated. The fix is the following
> - when registering a service the mandatory {{objectClass}} property must be set for the {{ServiceReference}}'s properties
> - implement simple filtering based on the {{objectClass}} parameter in {{MockBundleContext}}
> - notify only interested {{ServiceListener}} instances based on the filter they are registered with



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)