You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Bertrand Delacretaz <bd...@apache.org> on 2016/01/28 12:23:40 UTC

SLING-5462 - MockServiceReference sorting is wrong w.r.t. service ranking

Hi,

It looks like we have another issue about the "correct" sort order for
service rankings, details at SLING-5462 - MockServiceReference sorts
the service rankings in the wrong direction compared to the OSGi
framework.

Fixing MockServiceReference is probably easy, but might break existing tests.

Or people might have code that behaves wrongly in a real OSGi
environment if it was tested with these mocks only.

So not sure how to proceed, thoughts?

-Bertrand

Re: SLING-5462 - MockServiceReference sorting is wrong w.r.t. service ranking

Posted by Konrad Windszus <ko...@gmx.de>.
Yes I agree.
I commented in https://issues.apache.org/jira/browse/SLING-5462 <https://issues.apache.org/jira/browse/SLING-5462> on how this should be fixed.
Konrad

> On 28 Jan 2016, at 13:51, Bertrand Delacretaz <bd...@apache.org> wrote:
> 
> Hi Konrad,
> 
> On Thu, Jan 28, 2016 at 1:47 PM, Konrad Windszus <ko...@gmx.de> wrote:
>> ...This definitely should be fixed on the MockServiceReference IMHO...
>> ... All the tests which rely on the wrong sorting must be fixed...
> 
> Yeah that should be easy for our tests, but tests written outside of
> Sling might break as well.
> 
> But it's probably better to have those tests break, to indicate that
> the behavior that they test might be wrong.
> 
> -Bertrand


Re: SLING-5462 - MockServiceReference sorting is wrong w.r.t. service ranking

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi Konrad,

On Thu, Jan 28, 2016 at 1:47 PM, Konrad Windszus <ko...@gmx.de> wrote:
> ...This definitely should be fixed on the MockServiceReference IMHO...
> ... All the tests which rely on the wrong sorting must be fixed...

Yeah that should be easy for our tests, but tests written outside of
Sling might break as well.

But it's probably better to have those tests break, to indicate that
the behavior that they test might be wrong.

-Bertrand

Re: SLING-5462 - MockServiceReference sorting is wrong w.r.t. service ranking

Posted by Konrad Windszus <ko...@gmx.de>.
I am sorry, I didn’t look closely enough. You actually sort the service references in the test code https://github.com/apache/sling/commit/898f5850c82c6a621ab8fc265fdda2ad8d18349d#diff-cb38b920345df2a5f3763908befbd29dR63 <https://github.com/apache/sling/commit/898f5850c82c6a621ab8fc265fdda2ad8d18349d#diff-cb38b920345df2a5f3763908befbd29dR63>.
This definitely should be fixed on the MockServiceReference IMHO. All the tests which rely on the wrong sorting must be fixed.


> On 28 Jan 2016, at 13:38, Konrad Windszus <ko...@gmx.de> wrote:
> 
> Hi Bertand,
> your test looks invalid to me.
> The Javadoc for BundleContext.getServiceReferences(…) doesn’t specify any order in which the services are returned (https://osgi.org/javadoc/r6/core/org/osgi/framework/BundleContext.html#getServiceReferences%28java.lang.Class,%20java.lang.String%29).
> In your test you compare the order of MockBundleContext.getServiceReferences() with the order for PaxExam Bundle Context(). This is invalid as there is no contract stating that there is any specific order on that method.
> Therefore you cannot decide which one is more correct.
> IMHO we shouldn’t change the order of the MockBundleContext. 
> But if there is an implementation relying on a specific order of this method, it must be fixed.
> Konrad
> 
> 
> 
>> On 28 Jan 2016, at 12:23, Bertrand Delacretaz <bd...@apache.org> wrote:
>> 
>> Hi,
>> 
>> It looks like we have another issue about the "correct" sort order for
>> service rankings, details at SLING-5462 - MockServiceReference sorts
>> the service rankings in the wrong direction compared to the OSGi
>> framework.
>> 
>> Fixing MockServiceReference is probably easy, but might break existing tests.
>> 
>> Or people might have code that behaves wrongly in a real OSGi
>> environment if it was tested with these mocks only.
>> 
>> So not sure how to proceed, thoughts?
>> 
>> -Bertrand
> 


Re: SLING-5462 - MockServiceReference sorting is wrong w.r.t. service ranking

Posted by Konrad Windszus <ko...@gmx.de>.
Hi Bertand,
your test looks invalid to me.
The Javadoc for BundleContext.getServiceReferences(…) doesn’t specify any order in which the services are returned (https://osgi.org/javadoc/r6/core/org/osgi/framework/BundleContext.html#getServiceReferences%28java.lang.Class,%20java.lang.String%29).
In your test you compare the order of MockBundleContext.getServiceReferences() with the order for PaxExam Bundle Context(). This is invalid as there is no contract stating that there is any specific order on that method.
Therefore you cannot decide which one is more correct.
IMHO we shouldn’t change the order of the MockBundleContext. 
But if there is an implementation relying on a specific order of this method, it must be fixed.
Konrad



> On 28 Jan 2016, at 12:23, Bertrand Delacretaz <bd...@apache.org> wrote:
> 
> Hi,
> 
> It looks like we have another issue about the "correct" sort order for
> service rankings, details at SLING-5462 - MockServiceReference sorts
> the service rankings in the wrong direction compared to the OSGi
> framework.
> 
> Fixing MockServiceReference is probably easy, but might break existing tests.
> 
> Or people might have code that behaves wrongly in a real OSGi
> environment if it was tested with these mocks only.
> 
> So not sure how to proceed, thoughts?
> 
> -Bertrand