[ 
https://issues.apache.org/jira/browse/COLLECTIONS-307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12659497#action_12659497
 ] 

Henri Yandell commented on COLLECTIONS-307:
-------------------------------------------

Thanks for the report Christian. The bug is because the subList call doesn't 
create a new set to represent uniqueness but instead uses the parent list's 
set. Easy enough to fix if we hardcode the type of set. Harder to do if we want 
to use the same Set as originally passed in as there's no guaranteed cloning 
method.

Tempted to do a helper method of:

if instanceof Cloneable
  clone
else if empty Constructor
  construct and use addAll
else use defaultValue (ie: HashSet)

> SetUniqueList.subList().contains() method checks against full parent list, 
> not sublist range
> --------------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-307
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-307
>             Project: Commons Collections
>          Issue Type: Bug
>          Components: List
>    Affects Versions: 3.2
>            Reporter: Christian Semrau
>            Priority: Minor
>             Fix For: 3.3
>
>
> The view returned by the subList() method of a SetUniqueList checks 
> contains() against the set of the original list.
> As shown by the following test snippet.
>               List list = new ArrayList();
>               List uniqueList = SetUniqueList.decorate(list);
>               uniqueList.add("Hello");
>               uniqueList.add("World");
>               List subList = list.subList(0, 0);
>               List subUniqueList = uniqueList.subList(0, 0);
>               assertFalse(subList.contains("World")); // passes
>               assertFalse(subUniqueList.contains("World")); // fails

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

Reply via email to