felix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Don Brown (JIRA)" <j...@apache.org>
Subject [jira] Commented: (FELIX-765) Invalid occasional OSGi filter toString() value
Date Tue, 14 Oct 2008 12:15:44 GMT

    [ https://issues.apache.org/jira/browse/FELIX-765?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12639402#action_12639402

Don Brown commented on FELIX-765:

I tried making the counter final in the and operator with no effect, but I'll try the others,
and let you know.  I might be able to give you the tests that I use to replicate the issue...I'll
look into it tomorrow.

> Invalid occasional OSGi filter toString() value
> -----------------------------------------------
>                 Key: FELIX-765
>                 URL: https://issues.apache.org/jira/browse/FELIX-765
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-1.2.2
>            Reporter: Don Brown
>            Assignee: Karl Pauls
>         Attachments: ldap.patch
> Rather frequently, under the right conditions, FilterImpl.toString() will generate an
invalid filter string.  In my case, this happens when Spring DM loads two bundles on two different
threads simultaneously when processing a number of OSGi service imports.  The actual stracktrace
isn't very useful since what Spring DM does internally is get a filter's string, pass that
around a bit, then try to give that to Felix, which causes an exception.  I narrowed the problem
down to the toString() method:
> java.lang.RuntimeException: Invalid filter string:(&some49(&(bean-name=some49)(plugins-host=true)))
> 	at org.apache.felix.framework.FilterImpl.checkFilter(FilterImpl.java:330)
> 	at org.apache.felix.framework.FilterImpl.toString(FilterImpl.java:244)
> 	at java.lang.String.valueOf(String.java:2615)
> 	at java.lang.StringBuffer.append(StringBuffer.java:220)
> 	at org.springframework.osgi.service.importer.DefaultOsgiServiceDependency.<init>(DefaultOsgiServiceDependency.java:53)
> 	at org.springframework.osgi.extender.internal.dependencies.startup.MandatoryImporterDependencyFactory.getServiceDependencies(MandatoryImporterDependencyFactory.java:69)
> 	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyServiceManager.findServiceDependencies(DependencyServiceManager.java:233)
> 	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.stageOne(DependencyWaiterApplicationContextExecutor.java:253)
> 	at org.springframework.osgi.extender.internal.dependencies.startup.DependencyWaiterApplicationContextExecutor.refresh(DependencyWaiterApplicationContextExecutor.java:173)
> 	at org.springframework.osgi.context.support.AbstractDelegatedExecutionApplicationContext.refresh(AbstractDelegatedExecutionApplicationContext.java:136)
> 	at org.springframework.osgi.extender.internal.activator.ContextLoaderListener$2.run(ContextLoaderListener.java:741)
> 	at java.lang.Thread.run(Thread.java:613)
> This checkFilter() method simply looks for invalid strings where the '&' character
isn't followed by a '(' character:
> public static void checkFilter(String filter)
>     {
>         if (filter != null)
>         {
>             boolean andFound = false;
>             for (int x=0; x<filter.length(); x++)
>             {
>                 char c = filter.charAt(x);
>                 if (c == '&') {
>                     andFound = true;
>                 } else if (andFound && c != '(') {
>                     throw new RuntimeException("Invalid filter string:"+filter);
>                 } else
>                     andFound = false;
>             }
>         }
>     }
> Deeper in the code, I put this check in Parser to find out when this invalid filter String
was being created (line 594):
>                 for (int x=0; x<tmp.length; x++) {
>                     if (tmp[x] instanceof ConstOperator) {
>                         System.out.println("Invalid tree constructed:"+tmp[x]);
>                     }
>                 }
> This detected when the const operator was incorrectly listed as a child of the AND operator,
but I also saw the PUSH operator a direct child as well.  
> Therefore, this issue seems related to FELIX-721, although I was unable to find a direct
fix.  For now, I'm commenting out the program cache in FilterImpl line 64, which fixes the
issue and has a negligible impact on performance from my testing.  Since we are seeing this
exception between 10% and 80% of the time, a slower Felix is preferable to a frequently broken

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message