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:
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.
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
rootDirectorycan be null — it is assigned at lines 1544-1551 where bothsession.getRootDirectory()can throw andmodelSource.getPath()can return null. But thegetEnhancedPropertiesmethod calls.toString()on it without null check:A null
rootDirectorythrowsNullPointerException, which is NOT caught by thecatch(IllegalStateException)block. This can crash the build entirely for POMs with a modelSource that has no path and no session root directory.