You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Don Brown (JIRA)" <ji...@apache.org> on 2008/10/14 10:11:44 UTC

[jira] Created: (FELIX-765) Invalid occasional OSGi filter toString() value

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


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

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


[jira] Commented: (FELIX-765) Invalid occasional OSGi filter toString() value

Posted by "Don Brown (JIRA)" <ji...@apache.org>.
    [ 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 startup.

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


[jira] Closed: (FELIX-765) Invalid occasional OSGi filter toString() value

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-765?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Richard S. Hall closed FELIX-765.
---------------------------------


> 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
>             Fix For: felix-1.4.0
>
>         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 startup.

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


[jira] Updated: (FELIX-765) Invalid occasional OSGi filter toString() value

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ 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

Don,

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

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


[jira] Commented: (FELIX-765) Invalid occasional OSGi filter toString() value

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-765?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12640113#action_12640113 ] 

Karl Pauls commented on FELIX-765:
----------------------------------

Any news on this one? If that didn't fix it then did you find out whether you can give me the tests?

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

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


[jira] Resolved: (FELIX-765) Invalid occasional OSGi filter toString() value

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-765?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls resolved FELIX-765.
------------------------------

       Resolution: Incomplete
    Fix Version/s: felix-1.4.0

I commited the patch as is since I didn't got any feedback. Please test it and close this issue if it fixes your problem or reopen it if not, respectively.

> 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
>             Fix For: felix-1.4.0
>
>         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 startup.

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


[jira] Assigned: (FELIX-765) Invalid occasional OSGi filter toString() value

Posted by "Karl Pauls (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/FELIX-765?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Karl Pauls reassigned FELIX-765:
--------------------------------

    Assignee: Karl Pauls

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

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