Christian Helmbold opened SPR-17289 and commented

The Spring Framework makes use of mutable objects in many places, but that hinders comprehensiblity and violates the principle of least astonishment. This is a general concern, but a concrete example is DefaultConversionService#addCollectionConverters.

This is closely related to the use of mutable objects in Spring in general and methods like afterPropertiesSet in particular. I suggest to construct objects in one go and pass everything to the constructor.

This is probably a bigger, fundamental issue, but I want to raise it, because I encountered different situations where the behavior of Spring was hard to understand and led to wasted hours of debugging. I hope this issue can be a starting point to move Spring to more immutability and one-step object construction -- and, in the end, to a cleaner, more comprehensible framework.


Affects: 5.0.8

Comment From: bclozel

While introducing more immutability in general is a good idea, this issue is very broad and we would rather address specific cases through focused issues or PRs. I believe we haven't made progress on this because it's hard to figure out actionable items out of this issue.

I'm closing this issue as a result. Just to be clear, we're not declining this in general - we are just looking for more actionable and focused issues on the matter.