gnodet-bot commented on code in PR #2306:
URL: https://github.com/apache/maven-resolver/pull/2306#discussion_r4518328583


##########
maven-resolver-impl/src/main/java/org/eclipse/aether/internal/impl/DefaultInstaller.java:
##########
@@ -177,10 +181,23 @@ private InstallResult install(SyncContext syncContext, 
RepositorySystemSession s
                 }
             }
             if (linkFailure != null) {
-                logger.warn(
-                        "Hard link not supported, falling back to copy for all 
artifacts: {}",
-                        linkFailure.getMessage(),
-                        linkFailure);
+                Path localRepoBasedir =
+                        
session.getLocalRepositoryManager().getRepository().getBasePath();

Review Comment:
   ⚠️ **NPE on null `basePath`:** `LocalRepository.getBasePath()` is documented 
as "may be `null`" and the implementation returns the field directly (no null 
guard). When `localRepoBasedir` is `null`, `logged.add(null)` on the 
`ConcurrentHashMap`-backed `Set` throws `NullPointerException` — crashing any 
install that hits a hard-link failure on a repository without a base path 
(custom `LocalRepositoryManager`, in-memory resolvers, misconfigured setups).
   
   Guard with a null check:
   
   ```suggestion
                   Path localRepoBasedir =
                           
session.getLocalRepositoryManager().getRepository().getBasePath();
                   if (localRepoBasedir == null) {
                       // No base path (custom or in-memory local repository 
manager) — log without dedup
                       logger.info(
                               "Hard link not supported for local repository, 
falling back to file copy."
                                       + " To suppress this message, set 
'{}=false'.",
                               ConfigurationProperties.INSTALLER_HARD_LINK);
                       if (logger.isDebugEnabled()) {
                           logger.debug("Hard link failure cause: {}", 
linkFailure.getMessage(), linkFailure);
                       }
                   } else {
   ```



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