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

   # DefaultModelBuilder: NPE on null rootDirectory
   
   **Found in:** maven-4.0.x branch
   **File:** 
`impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultModelBuilder.java`
 (lines 719-720)
   **Severity:** High
   
   ## Description
   
   `rootDirectory` can be null — it is assigned at lines 1544-1551 where both 
`session.getRootDirectory()` can throw and `modelSource.getPath()` can return 
null. But the `getEnhancedProperties` method calls `.toString()` on it without 
null check:
   
   ```java
   try {
       String root = rootDirectory.toString();
       String rootUri = rootDirectory.toUri().toString();
       ...
   } catch (IllegalStateException e) {
       // Root directory not available, continue without it
   }
   ```
   
   A null `rootDirectory` throws `NullPointerException`, which is NOT caught by 
the `catch(IllegalStateException)` block. This can crash the build entirely for 
POMs with a modelSource that has no path and no session root directory.


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