[ 
https://issues.apache.org/jira/browse/CURATOR-651?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Kezhu Wang closed CURATOR-651.
------------------------------
      Assignee:     (was: Jordan Zimmerman)
    Resolution: Information Provided

{{Collection}} is appropriate as there is no order guarantee from 
{{ServiceDiscovery}}.

> Why use Collection instead of List as return value
> --------------------------------------------------
>
>                 Key: CURATOR-651
>                 URL: https://issues.apache.org/jira/browse/CURATOR-651
>             Project: Apache Curator
>          Issue Type: Bug
>            Reporter: lilu
>            Priority: Major
>
> org.apache.curator.x.discovery.ServiceDiscovery#queryForInstances
> The implementation class internally calls 
> org.apache.curator.x.discovery.details.ServiceDiscoveryImpl#queryForInstances(java.lang.String,
>  org.apache.zookeeper.Watcher)
> The specific code is:
>  
> {code:java}
> @Override
> public Collection<ServiceInstance<T>> queryForInstances(String name) throws 
> Exception
> {
>     return queryForInstances(name, null);
> }
> List<ServiceInstance<T>> queryForInstances(String name, Watcher watcher) 
> throws Exception
> {
> // ...
> }{code}
> Why is List implicitly converted to Collection?
> This way I won't be able to use List.get(0) directly. but requires a 
> conversion.
> May I ask what is the reason for doing this?
> Thank you very much.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to