Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
3.5.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