NullPointerException in AbstractEarModule.resolveArtifact() if earExecutionContext not set

Open Beginner friendly
#514 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
86/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
java
Domain
build-system

Research direction

Open AbstractEarModule.java at line 158 and inspect resolveArtifact() together with setEarExecutionContext(). Add the requested handling for an unset execution context, then verify that calling resolveArtifact() before initialization reports the expected MojoExecutionException instead of a NullPointerException.

Written by the indexing model from the issue text.

Description

bug

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);
}
Dominant language
Java
Stars
14
Forks
29
Avg merge
1d 4h
Merged PRs (30d)
8

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/maven-ear-plugin

All issues in apache/maven-ear-plugin

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.