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

AbstractCollectionDecorator.decorated() should not be used internally

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0-alpha1, 4.0
    • None
    • None

    Description

      AbstractCollectionDecorator.decorated() is used internally to access the collection.
      However, the method is not final, so subclasses could override it.

      Yet the field is also exposed (protected).

      This is inconsistent.

      Is there any use-case for overriding the collection to use a different one?
      If so, having direct access as well is likely to cause problems.

      I think it would be better to use the field directly internally.
      The class Javadoc says the calls are forwarded to the underlying collection, but that is not strictly true if decorated() is overridden.

      If it is intended to allow this to be overridden, then the field needs to be protected against arbitrary read/write access.

      The field should probably be made private with a setter for use by deserialization only.

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            Unassigned Unassigned
            sebb Sebb
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment