[ 
https://issues.apache.org/jira/browse/SLING-11066?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17477664#comment-17477664
 ] 

Konrad Windszus commented on SLING-11066:
-----------------------------------------

The logic in 
https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/5af8c2bb5728184f22d3098967a57d5f1902789c/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrNodeResource.java#L236-L245
 uses the URI from the first provider in the list not throwing an exception. 
That would be the provider with the lowest rank which seems not very intuitive 
as this service would not be returned by 
https://docs.osgi.org/javadoc/osgi.core/8.0.0/org/osgi/framework/BundleContext.html#getServiceReference-java.lang.Class-.
 Instead it would probably make more sense to iterate from highest ranking to 
lowest and return the first valid URI. So in this case I would propose to sort 
the URIProvider references in a descending sort order to ensure that higher 
ranked implementations would take precedence.
[~cziegeler] WDYT?

> Sort URIProvider references
> ---------------------------
>
>                 Key: SLING-11066
>                 URL: https://issues.apache.org/jira/browse/SLING-11066
>             Project: Sling
>          Issue Type: Bug
>          Components: JCR
>    Affects Versions: JCR Resource 3.1.0
>            Reporter: Konrad Windszus
>            Assignee: Konrad Windszus
>            Priority: Major
>             Fix For: JCR Resource 3.2.0
>
>          Time Spent: 2h 40m
>  Remaining Estimate: 0h
>
> If multiple URIProvider services are provided the order is currently 
> non-deterministic due to the code in 
> https://github.com/apache/sling-org-apache-sling-jcr-resource/blob/5af8c2bb5728184f22d3098967a57d5f1902789c/src/main/java/org/apache/sling/jcr/resource/internal/helper/jcr/JcrResourceProvider.java#L156-L168.
>  Instead the implementations should be ordered according to the rules of 
> https://docs.osgi.org/javadoc/osgi.core/8.0.0/org/osgi/framework/ServiceReference.html#compareTo-java.lang.Object-



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to