Pankraz76 commented on PR #2287: URL: https://github.com/apache/maven/pull/2287#issuecomment-2869161451
> You're not working in a green field. You can't change the behavior of APIs and assume existing clients will adapt. Yes. ### Which clients are affected? When will they get in touch? Do they live inside our JVM — at runtime or even compile-time — like within this code repo's scope? If so, we should be able to test and adapt accordingly. If not — for example, clients using the Maven wrapper — they simply execute the `.jar` file and don’t interact with the API in a way where immutability would matter. The only case I can imagine is another method using the current API and directly manipulating the result. In that case, wrapping the result in a simple `new ArrayList<>(...)` is enough to make the list mutable again — that should do the trick. Whether we return a mutable list or they create one themselves doesn’t really matter. The scenario where code relies on mutating a shared reference doesn’t apply here, since `toList()` already returns a new list instance. Passing around mutable references would be questionable design and could violate data integrity and the getter/setter principle. The core change here is introducing immutability — which is a best practice and supports defensive programming. We also benefit from cleaner code through method argument validation, which is a welcome side effect. So overall, the change is meaningful in terms of thread safety and data integrity — it's justified. We just need to align the code accordingly — `reverting` potential issues or `bridging` them by explicitly creating a new list instance when needed. See also: [Create mutable list from array - Stack Overflow](https://stackoverflow.com/questions/11659173/create-mutable-list-from-array) Ideally, failing tests that throw `UnsupportedOperationException` will help identify any breaking points. https://docs.oracle.com/javase/9/core/creating-immutable-lists-sets-and-maps.htm#JSCOR-GUID-4F3E2B7D-CE90-4862-A78A-414FC08DA6E4 -- 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