gnodet opened a new pull request, #14026: URL: https://github.com/apache/maven/pull/14026
Backport of #13995 to `maven-4.0.x`. `VersionRange` caches and returns shared instances from `createFromVersionSpec()` and `createFromVersion()`, but `getRestrictions()` exposed the mutable backing list. Clearing a returned list corrupts subsequent range checks for every caller using the same cached specification. - Move the `Collections.unmodifiableList()` wrap into the private constructor so every code path (direct construction, `cloneOf()`, `restrict()`) produces an immutable restriction list from the start; remove the now-redundant wrapping in `restrict()` - Document `getRestrictions()` to state that the returned list is unmodifiable and non-null - Add parameterized tests verifying that cached, cloned, intersected, and version-only ranges all throw `UnsupportedOperationException` on mutation attempts and that the cache remains consistent after attempted mutation Cherry-picked from bd1d61041394fe485bb2902a6dc063290bb6ad8a. -- 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]
