Skip to content

NPE in BuildClasspathMojo when getResolvedDependencies returns null #1648

Description

@elharo

BuildClasspathMojo.execute() at line 199-205:

Set<Artifact> artifacts = getResolvedDependencies(true);

if (artifacts == null || artifacts.isEmpty()) {
    getLog().info("No dependencies found.");
}

List<Artifact> artList = new ArrayList<>(artifacts);  // NPE if null

When getResolvedDependencies() returns null, the code logs "No dependencies found." but then falls through to new ArrayList<>(null), which throws NullPointerException. There is no return statement after the null/empty check.

If artifacts is empty (not null), execution continues normally and produces an empty classpath string, which is harmless but inconsistent.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions