AmarGhugare opened a new pull request, #13995: URL: https://github.com/apache/maven/pull/13995
`VersionRange.createFromVersionSpec()` caches and returns shared instances, but `getRestrictions()` exposes their mutable backing list. Clearing that list changes later parses of the same specification: `[1.1234,2.5678]` contains `1.5000` before the mutation and rejects it afterward. Wrap the internally owned restriction list in the private constructor and document the getter's read-only result. This protects parsed ranges and deprecated clones consistently while preserving cache reuse and the distinction between the specification and literal-version factories. Attempts to modify these lists now throw `UnsupportedOperationException`, consistent with the existing immutability assumption documented by `cloneOf()` and the original [cache change](https://github.com/apache/maven/commit/8f9075d3ad9a787f0c8ffd4d0e24a9c4339ace1d). Added seven regression and control cases covering bounded, exact, union, and recommended-version specifications, clones, intersections, and literal-version ranges. Five cases failed before the fix. Validation on JDK 17 with Maven 3.10.0: ```text mvn -B -ntp -pl :maven-artifact -am verify ``` Passed: 90 unit tests and one module integration test, with no failures, errors, or skips. Checkstyle, Spotless, RAT, and all three selected reactor modules passed. The full Maven reactor and core integration-test suite were not run. --- - [x] I hereby declare this contribution to be licensed under the [Apache License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0) - [ ] I hereby declare that I have filed an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
