You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Christian Semrau (JIRA)" <ji...@apache.org> on 2008/11/12 17:59:44 UTC
[jira] Created: (COLLECTIONS-307)
SetUniqueList.subList().contains() method checks against full parent list,
not sublist range
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
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.
[jira] Commented: (COLLECTIONS-307)
SetUniqueList.subList().contains() method checks against full parent list,
not sublist range
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ 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.
[jira] Commented: (COLLECTIONS-307)
SetUniqueList.subList().contains() method checks against full parent list,
not sublist range
Posted by "Christian Semrau (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/COLLECTIONS-307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12646952#action_12646952 ]
Christian Semrau commented on COLLECTIONS-307:
----------------------------------------------
The same problem occurs with containsAll().
> 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
>
> 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.
[jira] Closed: (COLLECTIONS-307) SetUniqueList.subList().contains()
method checks against full parent list, not sublist range
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/COLLECTIONS-307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell closed COLLECTIONS-307.
-------------------------------------
Resolution: Fixed
svn ci -m "Applying my patch from COLLECTIONS-307. Fixes the bug raised by Christian Semrau that SetUniqueList.subList() was not redefining the uniqueness set when creating the sublist. " src
Sending src/java/org/apache/commons/collections/list/SetUniqueList.java
Sending src/test/org/apache/commons/collections/list/TestSetUniqueList.java
Transmitting file data ..
Committed revision 731498.
> 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
>
> Attachments: COLLECTIONS-307.patch
>
>
> 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.
[jira] Commented: (COLLECTIONS-307)
SetUniqueList.subList().contains() method checks against full parent list,
not sublist range
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/COLLECTIONS-307?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12659522#action_12659522 ]
Henri Yandell commented on COLLECTIONS-307:
-------------------------------------------
(Forgot how lame clone is in Java... so that becomes:
if empty Constructor
create empty instance
else use HashSet
fill either case with addAll
> 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.
[jira] Updated: (COLLECTIONS-307)
SetUniqueList.subList().contains() method checks against full parent list,
not sublist range
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/COLLECTIONS-307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell updated COLLECTIONS-307:
--------------------------------------
Attachment: COLLECTIONS-307.patch
Two tests and the suggested patch attached.
> 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
>
> Attachments: COLLECTIONS-307.patch
>
>
> 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.
[jira] Updated: (COLLECTIONS-307)
SetUniqueList.subList().contains() method checks against full parent list,
not sublist range
Posted by "Henri Yandell (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/COLLECTIONS-307?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Henri Yandell updated COLLECTIONS-307:
--------------------------------------
Fix Version/s: 3.3
> 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.