Pankraz76 commented on PR #2287: URL: https://github.com/apache/maven/pull/2287#issuecomment-2868705455
> This is not a drop in replacement. This changes a lot of modifiable lists to immutable lists. In some cases here this is clearly fine — e.g. when all that''s done next is findFirst — but others aren't so obvious. This is really, really hard to debug when it goes wrong. I would limit this PR to cases where the lsist does not escape the method or perhaps the class. ## Immutable Objects and Thread Safety If someone wants to deviate from the happy path, they should work with a copy of final and secure state - and by happy with that. ### Core Principles: 1. **Final/immutable by Default**: Everything should be `final/immutable` unless there's a compelling reason not to be. 2. **External Manipulation**: If external modification is absolutely necessary: - The requester should receive a defensive copy - All modifications must go through our controlled interface - We maintain the immutable original as the source of truth ### Important Considerations: - **Strict Data Control**: Every modifiable reference is a potential deviation from our secure, immutable approach. We don't allow external code to directly manipulate our internal state. - **Side Effect Prevention**: Non-final references can lead to unpredictable side effects and thread safety issues. ### Reference: [Immutable Objects - Thread Safety](https://en.wikipedia.org/wiki/Immutable_object#Thread_safety) ### Implementation Strategy: For production systems: 1. Audit to identify genuine needs for mutability 2. Create exception pathways with proper safeguards: - Defensive copying - Controlled mutation interfaces 3. Always preserve the immutable source 4. Document all deviation points rigorously -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@maven.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org