Uploaded image for project: 'Maven'
  1. Maven
  2. MNG-6164

Collections inconsistently immutable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 3.5.0
    • Fix Version/s: 3.6.0
    • Component/s: None
    • Labels:
      None

      Description

      There are plenty of places where empty collections are returned from public API in methods written like:

           public List<Exception> getExceptions()
           {
              return exceptions == null ? Collections.<Exception>emptyList() : exceptions;
           }
      

      The issue with this is that the empty list is immutable but the collection returned for the nun-null case is not immutable.

      All those methods should return a collection with consistent "mutability": either mutable, either immutable.

      Given empty immutable collections do not cause harm until now, switching consistently to immutable collections is more conservative and should not be risky

        Attachments

          Activity

            People

            • Assignee:
              michael-o Michael Osipov
              Reporter:
              schulte77 Christian Schulte
            • Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: