gnodet commented on code in PR #13389:
URL: https://github.com/apache/maven/pull/13389#discussion_r4227426257


##########
maven-core/src/main/java/org/apache/maven/artifact/repository/LegacyLocalRepositoryManager.java:
##########
@@ -72,7 +72,7 @@ public static RepositorySystemSession overlay(
                         
.equals(DefaultRepositorySystemSessionFactory.resolve(repository.getBasedir())))
 {
             return session;
         }
-        if (repository.getLayout() instanceof DefaultRepositoryLayout) {
+        if (repository.getLayout() instanceof DefaultRepositoryLayout && 
"local".equals(repository.getId())) {

Review Comment:
   The ID-based guard is fragile. More importantly, looking at `master` (4.x), 
the correct approach is already implemented there: `overlay()` **always** uses 
`LegacyLocalRepositoryManager` for any repo that isn't the session's local 
repo, and additionally guards against a `null` session.
   
   The fix for `maven-3.10.x` should mirror that: drop the 
`DefaultRepositoryLayout` branch entirely and handle the `null` session case:
   
   ```java
       public static RepositorySystemSession overlay(
               ArtifactRepository repository, RepositorySystemSession session, 
RepositorySystem system) {
           if (repository == null || repository.getBasedir() == null) {
               return session;
           }
   
           if (session != null) {
               LocalRepositoryManager lrm = session.getLocalRepositoryManager();
               if (lrm != null
                       && lrm.getRepository()
                               .getBasePath()
                               
.equals(DefaultRepositorySystemSessionFactory.resolve(repository.getBasedir())))
 {
                   return session;
               }
           } else {
               session = new DefaultRepositorySystemSession();
           }
   
           return new DefaultRepositorySystemSession(session)
                   .setLocalRepositoryManager(new 
LegacyLocalRepositoryManager(repository));
       }
   ```
   
   This restores 3.9.x semantics for staging repos while correctly handling a 
`null` session (as `master` already does).



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