Skip to content

NullPointerException in AbstractEarModule when generating module ID with unresolved artifact #512

Description

@elharo

Description

In AbstractEarModule.java:336-338, a NullPointerException occurs if generateId is true but the artifact has not been resolved:

if (generateId) {
    Artifact theArtifact = getArtifact();
    String generatedId = theArtifact.getType().toUpperCase() + "_" + theArtifact.getGroupId() + "."
            + theArtifact.getArtifactId();

getArtifact() is documented in the EarModule interface as returning null until the artifact is resolved. If a module's artifact is not yet resolved when generateId is true, .getType() throws an NPE.

Expected behavior

Add a null check before generating the ID:

if (generateId) {
    Artifact theArtifact = getArtifact();
    if (theArtifact == null) {
        return;
    }
    ...
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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