Skip to content

Add null check for artifact parameter in evaluateFileNameMapping - #72

Open
elharo wants to merge 1 commit into
masterfrom
fix/null-artifact-npe
Open

Add null check for artifact parameter in evaluateFileNameMapping#72
elharo wants to merge 1 commit into
masterfrom
fix/null-artifact-npe

Conversation

@elharo

@elharo elharo commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Problem

MappingUtils.evaluateFileNameMapping(String, Artifact) throws an opaque NullPointerException when artifact is null, making it difficult for callers to diagnose the issue:

NullPointerException: Cannot invoke "Artifact.getArtifactHandler()" because "artifact" is null

Fix

Added an explicit null check at the start of evaluateFileNameMapping that throws IllegalArgumentException with a clear message:

if (artifact == null) {
    throw new IllegalArgumentException("artifact cannot be null");
}

Test

Added mappingWithNullArtifact which verifies that IllegalArgumentException is thrown when null is passed for the artifact parameter.

All 7 tests pass.

Closes #62

evaluateFileNameMapping threw an opaque NullPointerException when
artifact was null. Add an explicit null check that throws
IllegalArgumentException with a clear message.

Also added a test that verifies the expected exception is thrown.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing null check on artifact parameter in evaluateFileNameMapping

1 participant