Skip to content

NullPointerException in AbstractEarModule.resolveArtifact() if earExecutionContext not set #514

Description

@elharo

Description

In AbstractEarModule.java:158, a NullPointerException occurs if resolveArtifact() is called before setEarExecutionContext():

final ArtifactRepository ar = earExecutionContext.getArtifactRepository();

Modules are created via a factory and then the execution context is set afterward. If resolveArtifact() is called before setEarExecutionContext() has been invoked, earExecutionContext is null and .getArtifactRepository() throws an NPE.

Expected behavior

Add a null guard:

if (earExecutionContext == null) {
    throw new MojoExecutionException("EarExecutionContext not initialized for module " + this);
}

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