apache / apache/maven-ear-plugin

NullPointerException in AbstractEarModule.resolveArtifact() if earExecutionContext not set

Open Beginner friendly
#514 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Java
Stars
14
Forks
29
Avg merge
1d 12h
Merged PRs (30d)
6

Description

## Description

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

```java
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:

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

Contributor guide

No contributing guide indexed for this repository

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.