In the original code, Builders and Setters were used concurrently. This approach could compromise object immutability in multi-threaded environments, potentially leading to undesirable side effects.
To mitigate this, Setters have been removed to enhance and ensure object immutability.
- Remove setters
- Add a builder method that references existing objects
- Enhance the immutability of collections returned by getters
- Add test code reflecting the changes
Comment From: markpollack
I've created https://github.com/spring-projects/spring-ai/issues/407 and https://github.com/spring-projects/spring-ai/issues/408 to discuss changes to how builders behave across the code base.
Comment From: markpollack
merged only the setter removal as 3938cc83ad823caa0fd6627f5e8a6a710a22c5db