You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Stuart McCulloch (JIRA)" <ji...@apache.org> on 2009/09/15 14:33:57 UTC

[jira] Created: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
--------------------------------------------------------------------------------------

                 Key: FELIX-1600
                 URL: https://issues.apache.org/jira/browse/FELIX-1600
             Project: Felix
          Issue Type: Bug
          Components: Framework
    Affects Versions: felix-2.0.0
            Reporter: Stuart McCulloch
             Fix For: felix-2.2.0


[ from http://markmail.org/message/pu5usr5s7vsweyv3 ]

I think there's a bug in our ServiceReference.isAssignableTo implementation...

the javadoc for this method states:

 "This method performs the following checks:

   1. Get the package name from the specified class name.
   2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
       find the source for the package. If no source is found then return true if the registrant bundle is
       equal to the specified bundle; otherwise return false.
   3. If the package source of the registrant bundle is equal to the package source of the specified
      bundle then return true; otherwise return false."

whereas our implementation does:

            // There are three situations that may occur here:
            //   1. The requester does not have a wire for the package.
            //   2. The provider does not have a wire for the package.
            //   3. Both have a wire for the package.
            // For case 1, we do not filter the service reference since we
            // assume that the bundle is using reflection or that it won't
            // use that class at all since it does not import it. For
            // case 2, we have to try to load the class from the class
            // loader of the service object and then compare the class
            // loaders to determine if we should filter the service
            // refernce. In case 3, we simply compare the exporting
            // modules from the package wiring to determine if we need
            // to filter the service reference.

assume both the provider and requester have no wire for the package
(as happens when a bundle uses it's own export, as in this situation)

the javadoc says isAssignableTo should return false, because the
provider has no wire and the provider != requester - but we'll return
true because the requester has no wire and we do that check first


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


[jira] Commented: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12758840#action_12758840 ] 

Richard S. Hall commented on FELIX-1600:
----------------------------------------

>From my perspective, you have a degenerate case since you have a requester with its own private copy of the interface it is querying. As it said in the comments, case 2 was specifically allowed because the assumption was the requesting bundle was using reflection. This is sort of extra-spec, but I am fairly certain Equinox does it the same way, since I have talk with the guys there about it.

However, I think I have committed a refinement to the algorithm with checks to see if the requester has no wire but still has access to the class. If so, then I compare the class, if not then always true. Could you please test again. Thanks!

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Commented: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761628#action_12761628 ] 

Richard S. Hall commented on FELIX-1600:
----------------------------------------

I have deployed new snapshots, let us know if everything is ok.

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>            Assignee: Karl Pauls
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Closed: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

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

Richard S. Hall closed FELIX-1600.
----------------------------------

    Resolution: Fixed
      Assignee: Richard S. Hall

Excellent! I will close this issue since you have verified that it works. Thanks a lot.

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>            Assignee: Richard S. Hall
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Closed: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

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

Richard S. Hall closed FELIX-1600.
----------------------------------


Thanks.

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>            Assignee: Karl Pauls
>             Fix For: felix-2.0.1
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Commented: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760384#action_12760384 ] 

Richard S. Hall commented on FELIX-1600:
----------------------------------------

Henning, could you please test again and let me know if the latest trunk/snapshot still works for you? Thanks.

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>            Assignee: Richard S. Hall
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Commented: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

Posted by "Henning Andersen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12758816#action_12758816 ] 

Henning Andersen commented on FELIX-1600:
-----------------------------------------

Tried to fix this locally, allow=false is not the solution. It seems to me that case 2 is symmetrical to case 3 and implementing case using the below code fixed the problem for our application and did not at a first glance seem to have any negative sideeffects.

            // Case 2: Only include service reference if the service
            // object uses the same class as the requester.
            else if (requesterWire == null)
            {
	            // If the provider has a wire to the requestor, we are OK. If not,
	            // then try to use the service registration to see if the requester's
	            // class is accessible.
	            if (!((BundleImpl) providerWire.getExporter().getBundle()).hasModule(requesterModule))
	            {
	                try
	                {
	                    // Load the class from the requesting bundle.
	                    Class requestClass = requesterModule.getClassByDelegation(className);
	                    // Get the service registration and ask it to check
	                    // if the service object is assignable to the requesting
	                    // bundle's class.
	                    allow = getRegistration().isClassAccessible(requestClass);
	                }
	                catch (Exception ex)
	                {
	                    // This should not happen, filter to be safe.
	                    allow = false;
	                }
	            }
	            else
	            {
	                // O.k. the provider is wired to the requestor's package, now check
	                // if the provider is wired to the latest version of the requestor, if so
	                // then allow else don't (the requestor has been updated but not refreshed).
	                allow = requesterModule == providerWire.getExporter();
	            }
            }


> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Commented: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

Posted by "Henning Andersen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12775433#action_12775433 ] 

Henning Andersen commented on FELIX-1600:
-----------------------------------------

Hi Karl and Richard, I finally got back to testing this - and it works, both in 2.0.1 and in org.apache.felix.framework-2.1.0-20091008.113048-6.jar. Thanks, Henning

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>            Assignee: Karl Pauls
>             Fix For: felix-2.0.1
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Commented: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

Posted by "Henning Andersen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12761574#action_12761574 ] 

Henning Andersen commented on FELIX-1600:
-----------------------------------------

Hi Karl, would it be possible to generate a new snapshot build to test against? Thanks, Henning

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>            Assignee: Karl Pauls
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Resolved: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

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

Karl Pauls resolved FELIX-1600.
-------------------------------

    Resolution: Fixed

I commited a fix as of revision 820985. Could you please re-test trunk and see whether it still works for you?

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>            Assignee: Karl Pauls
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Commented: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

Posted by "Richard S. Hall (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12758695#action_12758695 ] 

Richard S. Hall commented on FELIX-1600:
----------------------------------------

I have committed a potential fix for this. If someone wants to test trunk (or the latest snapshot) and let me know if it works, that would be great, thanks!

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Commented: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

Posted by "Henning Andersen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12758805#action_12758805 ] 

Henning Andersen commented on FELIX-1600:
-----------------------------------------

Unfortunately, it does not work - at least not in our case. We run into the new "case 2", having a requesterWire==null and providerWire filled in. I believe the new case 2 (the old 1.8.1 version case 1) should simply set allow=false instead of true? The comment on reflection seems like something one should not do, if you want to get the services as seen from a bundle, you need to use that modules bundle-context to ask for the services.

In our case we have one bundle A declaring

interface com.stibo.X

class com.stibo.Ximpl

and Ximpl is registered as a service of interface X in bundle-context of bundle A. Everything is not exported in this bundle.

We have another bundle B declaring (and exporting)

interface com.stibo.X

and a third bundle C (importing com.stibo package) declaring

class com.stibo.xxx.yyy.Ximpl2

and Ximpl2 is registered as a service of interface X in bundle-context of bundle C.

We see Ximpl2 when bundle A asks for services of com.stibo.X, but clearly, Ximpl2 is not compatible with the X in bundle A (and the X in bundle B is not visible in bundle A).

I tested this against the snapshot: org.apache.felix.framework-2.1.0-20090923.131858-1.jar

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Closed: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

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

Richard S. Hall closed FELIX-1600.
----------------------------------

    Resolution: Fixed

Great, thanks Henning. I will close this issue again.

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>            Assignee: Richard S. Hall
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Commented: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

Posted by "Henning Andersen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12758862#action_12758862 ] 

Henning Andersen commented on FELIX-1600:
-----------------------------------------

The fix seems to work perfectly, thanks...

Yes, the case is a bit degenerate, but nevertheless to fix our case properly and safely we had to include the service interface locally in an extra bundle.

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Reopened: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

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

Karl Pauls reopened FELIX-1600:
-------------------------------

      Assignee: Karl Pauls  (was: Richard S. Hall)

There is still an issue when the requester doesn't have a wire but the provider does and the service is a service factory. In that case, we should see whether the provider has access and if so whether the class is the same as of the requester. 

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>            Assignee: Karl Pauls
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Commented: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

Posted by "Henning Andersen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12758346#action_12758346 ] 

Henning Andersen commented on FELIX-1600:
-----------------------------------------

We ran into this issue too when using the ServiceTracker, which ends up calling ServiceRegistrationImpl.isAssignableTo, where case 1 causes a class cast exception in our application due to seeing a service object that is not compatible with the requesting  bundles classloader. A fix would be good news (though we should be able to filter the results ourselves).

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Commented: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

Posted by "Henning Andersen (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/FELIX-1600?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12760559#action_12760559 ] 

Henning Andersen commented on FELIX-1600:
-----------------------------------------

The new version also works - I tested the latest snapshot: org.apache.felix.framework-2.1.0-20090928.211315-3.jar. Thanks, Henning

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>            Assignee: Richard S. Hall
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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


[jira] Reopened: (FELIX-1600) ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire

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

Richard S. Hall reopened FELIX-1600:
------------------------------------


It turns out this fix is not 100% correct...it messes up when there is a service being provided under multiple interfaces and a client requests under one interface and doesn't have access to the other. I will need to look into some changes, then we will have to test it again.

> ServiceReference.isAssignableTo() always returns true if requesting bundle has no wire
> --------------------------------------------------------------------------------------
>
>                 Key: FELIX-1600
>                 URL: https://issues.apache.org/jira/browse/FELIX-1600
>             Project: Felix
>          Issue Type: Bug
>          Components: Framework
>    Affects Versions: felix-2.0.0
>            Reporter: Stuart McCulloch
>            Assignee: Richard S. Hall
>             Fix For: felix-2.2.0
>
>
> [ from http://markmail.org/message/pu5usr5s7vsweyv3 ]
> I think there's a bug in our ServiceReference.isAssignableTo implementation...
> the javadoc for this method states:
>  "This method performs the following checks:
>    1. Get the package name from the specified class name.
>    2. For the bundle that registered the service referenced by this ServiceReference (registrant bundle);
>        find the source for the package. If no source is found then return true if the registrant bundle is
>        equal to the specified bundle; otherwise return false.
>    3. If the package source of the registrant bundle is equal to the package source of the specified
>       bundle then return true; otherwise return false."
> whereas our implementation does:
>             // There are three situations that may occur here:
>             //   1. The requester does not have a wire for the package.
>             //   2. The provider does not have a wire for the package.
>             //   3. Both have a wire for the package.
>             // For case 1, we do not filter the service reference since we
>             // assume that the bundle is using reflection or that it won't
>             // use that class at all since it does not import it. For
>             // case 2, we have to try to load the class from the class
>             // loader of the service object and then compare the class
>             // loaders to determine if we should filter the service
>             // refernce. In case 3, we simply compare the exporting
>             // modules from the package wiring to determine if we need
>             // to filter the service reference.
> assume both the provider and requester have no wire for the package
> (as happens when a bundle uses it's own export, as in this situation)
> the javadoc says isAssignableTo should return false, because the
> provider has no wire and the provider != requester - but we'll return
> true because the requester has no wire and we do that check first

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