apache / apache/maven-ear-plugin

NullPointerException in AbstractEarMojo.isArtifactRegistered() when module artifact is null

Open Beginner friendly
#519 1 comment 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 `AbstractEarMojo.java:317`, `isArtifactRegistered()` can throw a NullPointerException:

```java
return currentList.stream().anyMatch(em -> em.getArtifact().equals(a));
```

`EarModule.getArtifact()` is documented as returning `null` until the artifact is resolved. If a module in `currentList` has not been resolved, `.getArtifact()` returns null and `null.equals(a)` throws an NPE.

## Expected behavior

Add a null guard:

```java
return currentList.stream().anyMatch(em -> em.getArtifact() != null && em.getArtifact().equals(a));
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Open AbstractEarMojo.java around line 317 and inspect isArtifactRegistered(), starting with the documented null behavior of EarModule.getArtifact(). Confirm the change prevents an unresolved module from causing a NullPointerException, then run the relevant Maven tests if available and verify resolved artifacts are still checked.

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
Active
Clarity
Clearly specified
Newbie friendliness
90/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.