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

Collections inconsistently immutable

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 3.5.0
    • 3.6.0
    • None
    • 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

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

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 10m
                10m