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

Steven Walters commented on SLING-5829:
---------------------------------------

I have concerns regarding the changes made here in FactoryPreconditions.java:

the code doesn't actually seem to handle the scenario of a ResourceProvider 
having multiple SERVICE_PIDs, instead such a provider is ignored in any 
String-based PID matching checks as {{String.equals(String[])}} will always be 
{{false}} (such as possibly occurring on [line 
99|http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/FactoryPreconditions.java?revision=1751888&view=markup&pathrev=1751888#l99]
 and [line 
106|http://svn.apache.org/viewvc/sling/trunk/bundles/resourceresolver/src/main/java/org/apache/sling/resourceresolver/impl/FactoryPreconditions.java?revision=1751888&view=markup&pathrev=1751888#l106])
Instead the change appears to only avoid the associated ClassCastException on 
attempting to cast a String[] or Collection to String.

so as it is currently, the Filter matching approach appears to be the only 
route in which this scenario will function as intended, using the PID for 
declaring requiredness will always fail for provider implementations that have 
multiple SERVICE_PIDs (which is likely to cause frustration sometime in the 
future).

It seems like if the SERVICE_PID is an array or collection, you would need to 
see if the PID string being compared is contained in the array/collection here 
to be truly functional.

The other changes to avoid the ClassCastException in 
ResourceProviderTracker.java in ignoring non String SERVICE_PIDS (making them 
always {{null}}) seem to come back to FactoryPreconditions again through 
{{ChangeListener.providerRemoved}} causing the FactoryPreconditions line 99 
logic to always be false, though I'm not sure what the consequences of this 
would actually be yet... maybe just some wasted computations to see that a 
possibly required provider is not available?

> Fix handling of SERVICE_PID
> ---------------------------
>
>                 Key: SLING-5829
>                 URL: https://issues.apache.org/jira/browse/SLING-5829
>             Project: Sling
>          Issue Type: Bug
>          Components: ResourceResolver
>            Reporter: Carsten Ziegeler
>            Assignee: Carsten Ziegeler
>             Fix For: Resource Resolver 1.5.0
>
>
> The value of the service property SERVICE_PID can either be String or 
> String[]. We should guard against String[].
> The resource resolver uses the PID for configuring required resource providers



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to