AmarGhugare opened a new issue, #13999:
URL: https://github.com/apache/maven/issues/13999

   ### Affected version
   
   Reproduced on the current `master` (4.2.0-SNAPSHOT), `maven-3.10.x` 
(3.10.2-SNAPSHOT), and `maven-3.9.x` (3.9.17-SNAPSHOT) sources. The earliest 
affected release has not been established.
   
   ### Bug description
   
   `VersionRange.createFromVersionSpec()` returns cached instances, but 
`getRestrictions()` exposes their mutable backing list. A caller can alter 
later version-range checks made by another caller using the same specification.
   
   ```java
   VersionRange first = VersionRange.createFromVersionSpec("[1.1234,2.5678]");
   ArtifactVersion version = new DefaultArtifactVersion("1.5000");
   first.containsVersion(version); // true
   
   first.getRestrictions().clear();
   
   VersionRange second = VersionRange.createFromVersionSpec("[1.1234,2.5678]");
   second == first; // true
   second.containsVersion(version); // false
   ```
   
   Expected: callers cannot modify shared cached restrictions or change another 
caller's version checks. Actual: clearing or replacing entries in the returned 
list corrupts the cached range. Deprecated `cloneOf()` also returns mutable 
restrictions.
   
   ### Proposed fix and validation
   
   Protect the internally owned list in the private constructor and remove the 
redundant wrapping in `restrict()`. Mutation attempts then throw 
`UnsupportedOperationException`, while cache reuse is preserved.
   
   The fix and regressions are in #13995, with requested companion PRs #13997 
for Maven 3.10.x and #13998 for Maven 3.9.x. The cache and clone regression 
tests fail before the fix. On JDK 17, `mvn -B -ntp -pl :maven-artifact -am 
verify` passes on all three branches, including their module integration tests. 
The full reactor and core integration-test suites were not run.
   


-- 
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]

Reply via email to