You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Bruno P. Kinoshita (Jira)" <ji...@apache.org> on 2020/01/11 23:54:00 UTC

[jira] [Comment Edited] (COLLECTIONS-697) JavaDoc for FixedSizeList should warn that modifying underlying list is still allowed and is not prevented

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

Bruno P. Kinoshita edited comment on COLLECTIONS-697 at 1/11/20 11:53 PM:
--------------------------------------------------------------------------

Added missing changes.xml entry in [64420e34cc20b08d4386cfbfec5aaa3f49973c10|[https://github.com/apache/commons-collections/commit/64420e34cc20b08d4386cfbfec5aaa3f49973c10]|https://github.com/apache/commons-collections/commit/64420e34cc20b08d4386cfbfec5aaa3f49973c10]


was (Author: kinow):
Added missing changes.xml entry in [64420e34cc20b08d4386cfbfec5aaa3f49973c10](https://github.com/apache/commons-collections/commit/64420e34cc20b08d4386cfbfec5aaa3f49973c10)

> JavaDoc for FixedSizeList should warn that modifying underlying list is still allowed and is not prevented
> ----------------------------------------------------------------------------------------------------------
>
>                 Key: COLLECTIONS-697
>                 URL: https://issues.apache.org/jira/browse/COLLECTIONS-697
>             Project: Commons Collections
>          Issue Type: Bug
>    Affects Versions: 4.4
>            Reporter: Ranjan George
>            Priority: Major
>             Fix For: 4.5
>
>
> I just noticed that it is not explicitly mentioned in the JavaDoc that modifying the underlying list of a FixedSizeList would actually land up modifying the list of the constructed FixedSizeList.  Not sure if this was by design, but at the very list I think the JavaDoc should caution against this.
> Following is a test case that written that you could use to check this.
> {code:java}
> public void testAllowsMutationOfUnderlyingCollection() {
>  List<String> decoratedList = new ArrayList<>();
>  decoratedList.add("item 1");
>  decoratedList.add("item 2");
>  //
>  FixedSizeList<String> fixedSizeList = FixedSizeList.fixedSizeList(decoratedList);
>  int sizeBefore = fixedSizeList.size();
>  //
>  boolean changed = decoratedList.add("New Value");
>  Assert.assertTrue(changed);
>  //
>  Assert.assertEquals("Modifying an the underlying list is allowed", sizeBefore + 1, fixedSizeList.size());
> }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)