Skip to content

[maven-4.0.x] DefaultInheritanceAssembler: NPE from null artifactId #12603

Description

@elharo

DefaultInheritanceAssembler: NPE from null artifactId

Found in: maven-4.0.x branch
File: impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultInheritanceAssembler.java (lines 99-109)
Severity: Medium

Description

child.getArtifactId() can return null for POMs that inherit their artifactId. At line 128, childName.equals(childDirectory) would then NPE:

String childName = child.getArtifactId();                    // can be null
...
if (child.getProjectDirectory() != null) {
    childName = child.getProjectDirectory().getFileName().toString();  // getFileName() can return null
}

Additionally, child.getProjectDirectory().getFileName() returns null for root paths (e.g., /), causing NPE at .toString().

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions