You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "ASF GitHub Bot (JIRA)" <ji...@apache.org> on 2018/10/02 17:49:00 UTC
[jira] [Commented] (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=16635893#comment-16635893 ]
ASF GitHub Bot commented on COLLECTIONS-697:
--------------------------------------------
GitHub user george-ranjan opened a pull request:
https://github.com/apache/commons-collections/pull/55
COLLECTIONS-697 Added relevant JavaDoc and a test which proves
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.
This Pull Request has the necessary updates to the JavaDoc and a test that proves the findings.
NOTE: this is my first PR and I have tried to follow the guidelines. Pleas let me know if I need to do anything more. Thanks!
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/george-ranjan/commons-collections COLLECTIONS-697_FixedSizeList
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/commons-collections/pull/55.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #55
----
commit 1517ed304eef7737b7175a997d77cca384be8631
Author: george-ranjan <ge...@...>
Date: 2018-10-02T17:44:07Z
COLLECTIONS-697 Added relevant JavaDoc and a test which proves
----
> 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
> Reporter: Ranjan George
> Priority: Major
>
> 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
(v7.6.3#76005)