kec opened a new pull request, #13296:
URL: https://github.com/apache/maven/pull/13296

   Fixes #13295.
   
   ### What and why
   `MavenSnapshotMetadata.getKey` built the merge key as `classifier + ':' + 
extension`.
   - A `<snapshotVersion>` read from existing metadata **without** a 
`<classifier>` element has a `null` classifier, giving the key `"null:pom"`. 
Maven 3 writes metadata that way, and so do repository managers that regenerate 
it, such as Nexus Repository 3.
   - A new artifact without a classifier has `""`, giving `":pom"`.
   
   The keys never match, so `RemoteSnapshotMetadata.merge` keeps the previous 
build's entry beside the new one. After one deploy onto such metadata, Maven 
4.0.0-rc-7 lists the main `pom` twice: the new build and the stale one. Maven 
3.9.11 replaces it. The reproduction is in the issue.
   
   ### How
   `getKey` treats a `null` classifier as `""`. The change is applied in 
`impl/maven-impl` and in the identical copy in 
`compat/maven-resolver-provider`, so both stay alike.
   
   ### Tests
   New `RemoteSnapshotMetadataTest` in `maven-impl`. It reads existing metadata 
through `MetadataStaxReader`, as a deploy does, then checks three things:
   - the new build replaces an entry that has no `<classifier>` element (this 
test **fails without the fix**);
   - entries for other classifiers that weren't redeployed are kept;
   - an entry with an empty `<classifier>` element is replaced too.
   
   `mvn verify` results:
   - `compat/maven-resolver-provider`: passes.
   - `impl/maven-impl`: all pass except 
`DefaultModelBuilderTest.testMergeRepositories`, which fails the same way on 
untouched `master` in my environment. I believe it's local; my `settings.xml` 
mirrors all repositories.
   
   This is a 4.0 regression, so a backport to `maven-4.0.x` would be 
appreciated.
   
   ---
   
   - [x] Your pull request should address just one issue, without pulling in 
other changes.
   - [x] Write a pull request description that is detailed enough to understand 
what the pull request does, how, and why.
   - [x] Each commit in the pull request should have a meaningful subject line 
and body.
   - [x] Write unit tests that match behavioral changes, where the tests fail 
if the changes to the runtime are not applied.
   - [x] Run `mvn verify` to make sure basic checks pass.
   - [ ] You have run the [Core 
IT](https://maven.apache.org/core-its/core-it-suite/) successfully.
   
   - [x] I hereby declare this contribution to be licenced under the [Apache 
License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
   


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