felix-dev mailing list archives

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

     [ https://issues.apache.org/jira/browse/FELIX-765?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel

Karl Pauls updated FELIX-765:

    Attachment: ldap.patch


I'm sorry that you have so many issues with our ldap filter. It's great so, that we seem to
get some of the bugs figured out. Can you please see whether the attached patch makes a difference?
It's just a guess but it might be the answer already. If not then I will have to try to reproduce
the error first...

> 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
>         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