apache / apache/maven-ear-plugin

NullPointerException in AbstractEarModule when generating module ID with unresolved artifact

Open Beginner friendly
#512 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:336-338`, a NullPointerException occurs if `generateId` is true but the artifact has not been resolved:

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

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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with AbstractEarModule.java:336-338 and the EarModule interface documentation for getArtifact(). Exercise the generateId path with an unresolved artifact and verify that it no longer throws a NullPointerException while resolved artifacts still receive their generated IDs.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
78/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.