Uploaded image for project: 'Commons Collections'
  1. Commons Collections
  2. COLLECTIONS-697

JavaDoc for FixedSizeList should warn that modifying underlying list is still allowed and is not prevented

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 4.4
    • 4.5.0-M1
    • None
    • None

    Description

      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.

      
      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());
      }
      
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            george.ranjan@gmail.com Ranjan George
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: